- protected void processTemplate(Request request, Template template) {
- Set<Sone> localSones = webInterface.core().localSones();
- template.set("sones", localSones);
+ protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
+ /* get all own identities. */
+ List<Sone> localSones = new ArrayList<Sone>(webInterface.getCore().getLocalSones());
+ Collections.sort(localSones, Sone.NICE_NAME_COMPARATOR);
+ templateContext.set("sones", localSones);
+ if (request.getMethod() == Method.POST) {
+ String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100);
+ Sone selectedSone = webInterface.getCore().getLocalSone(soneId, false);
+ if (selectedSone != null) {
+ setCurrentSone(request.getToadletContext(), selectedSone);
+ String target = request.getHttpRequest().getParam("target");
+ if ((target == null) || (target.length() == 0)) {
+ target = "index.html";
+ }
+ throw new RedirectException(target);
+ }
+ }
+ List<OwnIdentity> ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.getCore());
+ templateContext.set("identitiesWithoutSone", ownIdentitiesWithoutSone);