List of usage examples for org.apache.wicket.markup.html.basic Label getMarkupId
public String getMarkupId()
From source file:com.evolveum.midpoint.web.component.message.TempMessagePanel.java
License:Apache License
private void initLayout(final IModel<FeedbackMessage> message) { Label label = new Label("message", new LoadableModel<String>(false) { @Override//from ww w . j a va2 s. com protected String load() { return getTopMessage(message); } }); label.add(new AttributeAppender("class", new LoadableModel<String>() { @Override protected String load() { return getLabelCss(message); } }, " ")); label.setOutputMarkupId(true); label.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("tempMessagePanel.message." + FeedbackMessagePanel.createMessageTooltip(message)); } })); add(label); WebMarkupContainer content = new WebMarkupContainer("content"); if (message.getObject().getMessage() instanceof OpResult) { content.add(new AttributeAppender("class", new LoadableModel<String>(false) { @Override protected String load() { return getDetailsCss(new PropertyModel<OpResult>(message, "message")); } }, " ")); } else { content.setVisible(false); } content.setMarkupId(label.getMarkupId() + "_content"); content.add(new AttributeModifier("title", new LoadableModel<String>() { @Override protected String load() { return getString("tempMessagePanel.message." + FeedbackMessagePanel.createMessageTooltip(message)); } })); add(content); WebMarkupContainer operationPanel = new WebMarkupContainer("operationPanel"); content.add(operationPanel); operationPanel.add(new Label("operation", new LoadableModel<String>() { @Override protected String load() { OpResult result = (OpResult) message.getObject().getMessage(); String resourceKey = OperationResultPanel.OPERATION_RESOURCE_KEY_PREFIX + result.getOperation(); return getPage().getString(resourceKey, null, resourceKey); } })); WebMarkupContainer countPanel = new WebMarkupContainer("countPanel"); countPanel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { OpResult result = (OpResult) message.getObject().getMessage(); return result.getCount() > 1; } }); countPanel.add(new Label("count", new PropertyModel<String>(message, "message.count"))); operationPanel.add(countPanel); ListView<Param> params = new ListView<Param>("params", OperationResultPanel.createParamsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Param> item) { item.add(new Label("paramName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("paramValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; content.add(params); ListView<Context> contexts = new ListView<Context>("contexts", OperationResultPanel.createContextsModel(new PropertyModel<OpResult>(message, "message"))) { @Override protected void populateItem(ListItem<Context> item) { item.add(new Label("contextName", new PropertyModel<Object>(item.getModel(), "name"))); item.add(new Label("contextValue", new PropertyModel<Object>(item.getModel(), "value"))); } }; content.add(contexts); initExceptionLayout(content, message); }
From source file:com.googlecode.wicket.jquery.ui.form.slider.AbstractSlider.java
License:Apache License
/** * Constructor/*from w w w. j a v a 2 s. co m*/ * @param id the markup id * @param model the {@link IModel} * @param label {@link Label} on which the current slide value will be displayed */ public AbstractSlider(String id, IModel<T> model, Label label) { super(id, model); label.setDefaultModel(model); label.setOutputMarkupId(true); this.setLabelId(label.getMarkupId()); }
From source file:de.alpharogroup.wicket.components.examples.tooltips.TooltipsExamplePanel.java
License:Apache License
public TooltipsExamplePanel(final String id, final IModel<?> model) { super(id, model); final Label label = ComponentFactory.newLabel("tooltipTestLabel", Model.of("Im example for tooltipster.")); final TooltipsterSettings tooltipsterSettings = TooltipsterSettings.builder().build(); tooltipsterSettings.getAnimation().setValue("grow"); tooltipsterSettings.getArrow().setValue(false); tooltipsterSettings.getContent().setValue("Loading foo..."); final TooltipsterJsGenerator tooltipsterJsGenerator = new TooltipsterJsGenerator(tooltipsterSettings, label.getMarkupId()); final String js = tooltipsterJsGenerator.generateJs(); label.add(JavascriptAppenderBehavior.builder().id("tooltip_" + label.getMarkupId()).javascript(js).build()); add(label);/* w w w.j a v a 2 s . c om*/ }
From source file:org.sakaiproject.delegatedaccess.tool.pages.AdministratePage.java
License:Educational Community License
public AdministratePage() { disableLink(administrateLink);/* w w w . j a va2 s . c o m*/ //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Add Delegated Access to My Workspaces: final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() { @Override public String getObject() { String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus(); if (lastRanInfoStr == null) { lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject(); } else { try { long lastRanInfoInt = Long.parseLong(lastRanInfoStr); if (lastRanInfoInt == -1) { return new ResourceModel("addDaMyworkspace.job.status.failed").getObject(); } else if (lastRanInfoInt == 0) { return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject(); } else { Date successDate = new Date(lastRanInfoInt); return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate); } } catch (Exception e) { return new ResourceModel("na").getObject(); } } return lastRanInfoStr; } }); addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true); final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId(); add(addDaMyworkspaceStatusLabel); Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm"); AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { projectLogic.scheduleAddDAMyworkspaceJobStatus(); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.addComponent(formFeedback); target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.addComponent(addDaMyworkspaceStatusLabel, addDaMyworkspaceStatusLabelId); } }; addDaMyworkspaceForm.add(addDaMyworkspaceButton); add(addDaMyworkspaceForm); }
From source file:org.sakaiproject.delegatedaccess.tool.pages.ShoppingEditPage.java
License:Educational Community License
public ShoppingEditPage() { disableLink(shoppingAdminLink);//from w ww .j av a 2 s .c om blankRestrictedTools = projectLogic.getEntireToolsList(); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Form Feedback2 (Saved/Error) final Label formFeedback2 = new Label("formFeedback2"); formFeedback2.setOutputMarkupPlaceholderTag(true); final String formFeedback2Id = formFeedback2.getMarkupId(); add(formFeedback2); //FORM: Form form = new Form("form"); add(form); //Filter Forum Form filterForm = new Form("filterform"); add(filterForm); //bulk add, edit, delete link: filterForm.add(new Link("bulkEditLink") { @Override public void onClick() { setResponsePage(new ShoppingEditBulkPage()); } }); //Filter Search: //Dropdown final ChoiceRenderer choiceRenderer = new ChoiceRenderer("label", "value"); final PropertyModel<SelectOption> filterHierarchydModel = new PropertyModel<SelectOption>(this, "filterHierarchy"); List<SelectOption> hierarchyOptions = new ArrayList<SelectOption>(); String[] hierarchy = sakaiProxy .getServerConfigurationStrings(DelegatedAccessConstants.HIERARCHY_SITE_PROPERTIES); if (hierarchy == null || hierarchy.length == 0) { hierarchy = DelegatedAccessConstants.DEFAULT_HIERARCHY; } for (int i = 0; i < hierarchy.length; i++) { hierarchyOptions.add(new SelectOption(hierarchy[i], "" + i)); } final DropDownChoice filterHierarchyDropDown = new DropDownChoice("filterHierarchyLevel", filterHierarchydModel, hierarchyOptions, choiceRenderer); filterHierarchyDropDown.setOutputMarkupPlaceholderTag(true); filterForm.add(filterHierarchyDropDown); //Filter Search field final PropertyModel<String> filterSearchModel = new PropertyModel<String>(this, "filterSearch"); final TextField<String> filterSearchTextField = new TextField<String>("filterSearch", filterSearchModel); filterSearchTextField.setOutputMarkupPlaceholderTag(true); filterForm.add(filterSearchTextField); //submit button: filterForm.add(new AjaxButton("filterButton", new StringResourceModel("filter", null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getTree().getModelObject().getRoot(); //check that no nodes have been modified if (!modifiedAlert && anyNodesModified(rootNode)) { formFeedback.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); modifiedAlert = true; //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); } else { //now go through the tree and make sure its been loaded at every level: Integer depth = null; if (filterHierarchy != null && filterHierarchy.getValue() != null && !"".equals(filterHierarchy.getValue().trim())) { try { depth = Integer.parseInt(filterHierarchy.getValue()); } catch (Exception e) { //number format exception, ignore } } if (depth != null && filterSearch != null && !"".equals(filterSearch.trim())) { expandTreeToDepth(rootNode, depth, DelegatedAccessConstants.SHOPPING_PERIOD_USER, blankRestrictedTools, null, false, true, false, filterSearch); getTree().updateTree(target); } modifiedAlert = false; } } }); filterForm.add(new AjaxButton("filterClearButton", new StringResourceModel("clear", null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getTree().getModelObject().getRoot(); //check that no nodes have been modified if (!modifiedAlert && anyNodesModified(rootNode)) { formFeedback.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); modifiedAlert = true; //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); } else { filterSearch = ""; filterHierarchy = null; target.addComponent(filterSearchTextField); target.addComponent(filterHierarchyDropDown); ((NodeModel) rootNode.getUserObject()).setAddedDirectChildrenFlag(false); rootNode.removeAllChildren(); getTree().getTreeState().collapseAll(); getTree().updateTree(target); modifiedAlert = false; } } }); //tree: //create a map of the realms and their roles for the Role column final Map<String, String> roleMap = projectLogic.getRealmRoleDisplay(true); String largestRole = ""; for (String role : roleMap.values()) { if (role.length() > largestRole.length()) { largestRole = role; } } //set the size of the role Column (shopper becomes) int roleColumnSize = 80 + largestRole.length() * 6; if (roleColumnSize < 155) { roleColumnSize = 155; } boolean singleRoleOptions = false; if (roleMap.size() == 1) { String[] split = null; for (String key : roleMap.keySet()) { split = key.split(":"); } if (split != null && split.length == 2) { //only one option for role, so don't bother showing it in the table singleRoleOptions = true; defaultRole = split; } } final TreeModel treeModel = projectLogic.createTreeModelForShoppingPeriod(sakaiProxy.getCurrentUserId()); List<IColumn> columnsList = new ArrayList<IColumn>(); columnsList.add(new PropertyEditableColumnCheckbox(new ColumnLocation(Alignment.LEFT, 35, Unit.PX), "", "userObject.directAccess", DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER)); columnsList.add(new PropertyTreeColumn(new ColumnLocation(Alignment.MIDDLE, 100, Unit.PROPORTIONAL), "", "userObject.node.description")); if (!singleRoleOptions) { columnsList.add( new PropertyEditableColumnDropdown(new ColumnLocation(Alignment.RIGHT, roleColumnSize, Unit.PX), new StringResourceModel("shoppersBecome", null).getString(), "userObject.roleOption", roleMap, DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER, null)); } columnsList.add(new PropertyEditableColumnDate(new ColumnLocation(Alignment.RIGHT, 104, Unit.PX), new StringResourceModel("startDate", null).getString(), "userObject.shoppingPeriodStartDate", true)); columnsList.add(new PropertyEditableColumnDate(new ColumnLocation(Alignment.RIGHT, 104, Unit.PX), new StringResourceModel("endDate", null).getString(), "userObject.shoppingPeriodEndDate", false)); columnsList.add(new PropertyEditableColumnList(new ColumnLocation(Alignment.RIGHT, 120, Unit.PX), new StringResourceModel("showToolsHeader", null).getString(), "userObject.restrictedAuthTools", DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER, DelegatedAccessConstants.TYPE_LISTFIELD_TOOLS)); columnsList.add(new PropertyEditableColumnAdvancedOptions(new ColumnLocation(Alignment.RIGHT, 92, Unit.PX), new StringResourceModel("advanced", null).getString(), "userObject.shoppingPeriodRevokeInstructorEditable", DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER)); IColumn columns[] = columnsList.toArray(new IColumn[columnsList.size()]); final boolean activeSiteFlagEnabled = sakaiProxy.isActiveSiteFlagEnabled(); final ResourceReference inactiveWarningIcon = new CompressedResourceReference(ShoppingEditPage.class, "images/bullet_error.png"); final ResourceReference instructorEditedIcon = new CompressedResourceReference(ShoppingEditPage.class, "images/bullet_red.png"); //a null model means the tree is empty tree = new TreeTable("treeTable", treeModel, columns) { @Override public boolean isVisible() { return treeModel != null; } protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) { tree.getTreeState().selectNode(node, false); boolean anyAdded = false; if (!tree.getTreeState().isNodeExpanded(node) && !((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()) .isAddedDirectChildrenFlag()) { anyAdded = projectLogic.addChildrenNodes(node, DelegatedAccessConstants.SHOPPING_PERIOD_USER, blankRestrictedTools, false, null, true, false); ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).setAddedDirectChildrenFlag(true); } if (anyAdded) { collapseEmptyFoldersHelper((DefaultMutableTreeNode) node); } if (!tree.getTreeState().isNodeExpanded(node) || anyAdded) { tree.getTreeState().expandNode(node); } else { tree.getTreeState().collapseNode(node); } } protected void onJunctionLinkClicked(AjaxRequestTarget target, TreeNode node) { //the nodes are generated on the fly with ajax. This will add any child nodes that //are missing in the tree. Expanding and collapsing will refresh the tree node if (tree.getTreeState().isNodeExpanded(node) && !((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()) .isAddedDirectChildrenFlag()) { boolean anyAdded = projectLogic.addChildrenNodes(node, DelegatedAccessConstants.SHOPPING_PERIOD_USER, blankRestrictedTools, false, null, true, false); ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).setAddedDirectChildrenFlag(true); if (anyAdded) { collapseEmptyFoldersHelper((DefaultMutableTreeNode) node); } } } @Override protected boolean isForceRebuildOnSelectionChange() { return true; }; protected org.apache.wicket.ResourceReference getNodeIcon(TreeNode node) { if (activeSiteFlagEnabled && !((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).isActive()) { return inactiveWarningIcon; } else if (((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).isInstructorEdited()) { return instructorEditedIcon; } else { return super.getNodeIcon(node); } } @Override protected MarkupContainer newNodeLink(MarkupContainer parent, String id, TreeNode node) { try { parent.add(new AttributeAppender("title", new Model( ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).getNode().description), " ")); } catch (Exception e) { log.error(e.getMessage(), e); } return super.newNodeLink(parent, id, node); } }; if (singleRoleOptions) { tree.add(new AttributeAppender("class", new Model("noRoles"), " ")); } form.add(tree); //updateButton button: AjaxButton updateButton = new AjaxButton("update", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form arg1) { try { //save node access and roll information: updateNodeAccess(DelegatedAccessConstants.SHOPPING_PERIOD_USER, defaultRole); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.save")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("success.save")); formFeedback2.add(new AttributeModifier("class", true, new Model("success"))); target.addComponent(formFeedback2); } catch (Exception e) { log.error(e.getMessage(), e); formFeedback.setDefaultModel(new ResourceModel("failed.save")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("failed.save")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); } //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); modifiedAlert = false; } @Override public boolean isVisible() { return treeModel != null; } }; form.add(updateButton); //cancelButton button: Button cancelButton = new Button("cancel") { @Override public void onSubmit() { setResponsePage(new UserPage()); } @Override public boolean isVisible() { return treeModel != null; } }; form.add(cancelButton); //Access Warning: Label noAccessLabel = new Label("noAccess") { @Override public boolean isVisible() { return treeModel == null; } }; noAccessLabel.setDefaultModel(new StringResourceModel("noShoppingAdminAccess", null)); add(noAccessLabel); add(new Image("inactiveLegend", inactiveWarningIcon) { @Override public boolean isVisible() { return activeSiteFlagEnabled; } }); //setup legend: final ResourceReference nodeIcon = new CompressedResourceReference(DefaultAbstractTree.class, "res/folder-closed.gif"); final ResourceReference siteIcon = new CompressedResourceReference(DefaultAbstractTree.class, "res/item.gif"); add(new Label("legend", new StringResourceModel("legend", null))); add(new Image("legendNode", nodeIcon)); add(new Label("legendNodeDesc", new StringResourceModel("legendNodeDesc", null))); add(new Image("legendSite", siteIcon)); add(new Label("legendSiteDesc", new StringResourceModel("legendSiteDesc", null))); add(new Image("legendInactive", inactiveWarningIcon)); add(new Label("legendInactiveDesc", new StringResourceModel("legendInactiveDesc", null))); add(new Image("legendInstructorEdited", instructorEditedIcon)); add(new Label("legendInstructorEditedDesc", new StringResourceModel("legendInstructorEditedDesc", null))); }
From source file:org.sakaiproject.delegatedaccess.tool.pages.UserEditPage.java
License:Educational Community License
public UserEditPage(final String userId, final String displayName) { blankRestrictedTools = projectLogic.getEntireToolsList(); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback);/* w ww .java 2s . c om*/ //Form Feedback2 (Saved/Error) final Label formFeedback2 = new Label("formFeedback2"); formFeedback2.setOutputMarkupPlaceholderTag(true); final String formFeedback2Id = formFeedback2.getMarkupId(); add(formFeedback2); //USER NAME & IMAGE: add(new Label("userName", displayName)); //FORM: Form form = new Form("form"); add(form); //Filter Forum Form filterForm = new Form("filterform"); add(filterForm); //Expand Collapse Link: filterForm.add(getExpandCollapseLink()); //Filter Search: //Dropdown final ChoiceRenderer choiceRenderer = new ChoiceRenderer("label", "value"); final PropertyModel<SelectOption> filterHierarchydModel = new PropertyModel<SelectOption>(this, "filterHierarchy"); List<SelectOption> hierarchyOptions = new ArrayList<SelectOption>(); String[] hierarchy = sakaiProxy .getServerConfigurationStrings(DelegatedAccessConstants.HIERARCHY_SITE_PROPERTIES); if (hierarchy == null || hierarchy.length == 0) { hierarchy = DelegatedAccessConstants.DEFAULT_HIERARCHY; } for (int i = 0; i < hierarchy.length; i++) { hierarchyOptions.add(new SelectOption(hierarchy[i], "" + i)); } final DropDownChoice filterHierarchyDropDown = new DropDownChoice("filterHierarchyLevel", filterHierarchydModel, hierarchyOptions, choiceRenderer); filterHierarchyDropDown.setOutputMarkupPlaceholderTag(true); filterForm.add(filterHierarchyDropDown); //Filter Search field final PropertyModel<String> filterSearchModel = new PropertyModel<String>(this, "filterSearch"); final TextField<String> filterSearchTextField = new TextField<String>("filterSearch", filterSearchModel); filterSearchTextField.setOutputMarkupPlaceholderTag(true); filterForm.add(filterSearchTextField); //submit button: filterForm.add(new AjaxButton("filterButton", new StringResourceModel("filter", null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getTree().getModelObject().getRoot(); //check that no nodes have been modified if (!modifiedAlert && anyNodesModified(rootNode)) { formFeedback.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); modifiedAlert = true; //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); } else { //now go through the tree and make sure its been loaded at every level: Integer depth = null; if (filterHierarchy != null && filterHierarchy.getValue() != null && !"".equals(filterHierarchy.getValue().trim())) { try { depth = Integer.parseInt(filterHierarchy.getValue()); } catch (Exception e) { //number format exception, ignore } } if (depth != null && filterSearch != null && !"".equals(filterSearch.trim())) { expandTreeToDepth(rootNode, depth, userId, blankRestrictedTools, accessAdminNodeIds, false, false, false, filterSearch); getTree().updateTree(target); } modifiedAlert = false; } } }); filterForm.add(new AjaxButton("filterClearButton", new StringResourceModel("clear", null)) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getTree().getModelObject().getRoot(); //check that no nodes have been modified if (!modifiedAlert && anyNodesModified(rootNode)) { formFeedback.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("modificationsPending")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); modifiedAlert = true; //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); } else { filterSearch = ""; filterHierarchy = null; target.addComponent(filterSearchTextField); target.addComponent(filterHierarchyDropDown); ((NodeModel) rootNode.getUserObject()).setAddedDirectChildrenFlag(false); rootNode.removeAllChildren(); getTree().getTreeState().collapseAll(); getTree().updateTree(target); modifiedAlert = false; } } }); //tree: //create a map of the realms and their roles for the Role column final Map<String, String> roleMap = projectLogic.getRealmRoleDisplay(false); String largestRole = ""; for (String role : roleMap.values()) { if (role.length() > largestRole.length()) { largestRole = role; } } //set the size of the role Column (shopper becomes) int roleColumnSize = 80 + largestRole.length() * 6; if (roleColumnSize < 155) { //for "Choose One" default option roleColumnSize = 155; } boolean singleRoleOptions = false; if (roleMap.size() == 1) { String[] split = null; for (String key : roleMap.keySet()) { split = key.split(":"); } if (split != null && split.length == 2) { //only one option for role, so don't bother showing it in the table singleRoleOptions = true; defaultRole = split; } } List<IColumn> columnsList = new ArrayList<IColumn>(); columnsList.add(new PropertyTreeColumn(new ColumnLocation(Alignment.MIDDLE, 100, Unit.PROPORTIONAL), "", "userObject.node.description")); if (sakaiProxy.isSuperUser()) { columnsList.add(new PropertyEditableColumnCheckbox(new ColumnLocation(Alignment.RIGHT, 70, Unit.PX), new StringResourceModel("accessAdmin", null).getString(), "userObject.accessAdmin", DelegatedAccessConstants.TYPE_ACCESS_ADMIN)); columnsList.add(new PropertyEditableColumnCheckbox(new ColumnLocation(Alignment.RIGHT, 90, Unit.PX), new StringResourceModel("shoppingPeriodAdmin", null).getString(), "userObject.shoppingPeriodAdmin", DelegatedAccessConstants.TYPE_SHOPPING_PERIOD_ADMIN)); } columnsList.add(new PropertyEditableColumnCheckbox(new ColumnLocation(Alignment.RIGHT, 68, Unit.PX), new StringResourceModel("siteAccess", null).getString(), "userObject.directAccess", DelegatedAccessConstants.TYPE_ACCESS)); if (!singleRoleOptions) { columnsList.add( new PropertyEditableColumnDropdown(new ColumnLocation(Alignment.RIGHT, roleColumnSize, Unit.PX), new StringResourceModel("userBecomes", null).getString(), "userObject.roleOption", roleMap, DelegatedAccessConstants.TYPE_ACCESS, sakaiProxy.isSuperUser() ? null : sakaiProxy.getSubAdminOrderedRealmRoles())); } columnsList.add(new PropertyEditableColumnList(new ColumnLocation(Alignment.RIGHT, 134, Unit.PX), new StringResourceModel("restrictedToolsHeader", null).getString(), "userObject.restrictedAuthTools", DelegatedAccessConstants.TYPE_ACCESS, DelegatedAccessConstants.TYPE_LISTFIELD_TOOLS)); //setup advanced options settings: Map<String, Object> advSettings = new HashMap<String, Object>(); advSettings.put(PropertyEditableColumnAdvancedUserOptions.SETTINGS_ALLOW_SET_BECOME_USER, sakaiProxy.isSuperUser() || sakaiProxy.allowAccessAdminsSetBecomeUserPerm()); columnsList .add(new PropertyEditableColumnAdvancedUserOptions(new ColumnLocation(Alignment.RIGHT, 92, Unit.PX), new StringResourceModel("advanced", null).getString(), "", advSettings)); IColumn columns[] = columnsList.toArray(new IColumn[columnsList.size()]); //if the user isn't a super user, they should only be able to edit the nodes they //have been granted accessAdmin privileges if (!sakaiProxy.isSuperUser()) { Set<HierarchyNodeSerialized> accessAdminNodes = projectLogic .getAccessAdminNodesForUser(sakaiProxy.getCurrentUserId()); accessAdminNodeIds = new ArrayList<String>(); if (accessAdminNodes != null) { for (HierarchyNodeSerialized node : accessAdminNodes) { accessAdminNodeIds.add(node.id); } } } final TreeModel treeModel = projectLogic.createEntireTreeModelForUser(userId, true, false); //a null model means the tree is empty tree = new TreeTable("treeTable", treeModel, columns) { @Override public boolean isVisible() { return treeModel != null; } protected void onNodeLinkClicked(AjaxRequestTarget target, TreeNode node) { //the nodes are generated on the fly with ajax. This will add any child nodes that //are missing in the tree. Expanding and collapsing will refresh the tree node tree.getTreeState().selectNode(node, false); boolean anyAdded = false; if (!tree.getTreeState().isNodeExpanded(node) && !((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()) .isAddedDirectChildrenFlag()) { anyAdded = projectLogic.addChildrenNodes(node, userId, blankRestrictedTools, false, accessAdminNodeIds, false, false); ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).setAddedDirectChildrenFlag(true); } if (anyAdded) { collapseEmptyFoldersHelper((DefaultMutableTreeNode) node); } if (!tree.getTreeState().isNodeExpanded(node) || anyAdded) { tree.getTreeState().expandNode(node); } else { tree.getTreeState().collapseNode(node); } } protected void onJunctionLinkClicked(AjaxRequestTarget target, TreeNode node) { //the nodes are generated on the fly with ajax. This will add any child nodes that //are missing in the tree. Expanding and collapsing will refresh the tree node if (tree.getTreeState().isNodeExpanded(node) && !((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()) .isAddedDirectChildrenFlag()) { boolean anyAdded = projectLogic.addChildrenNodes(node, userId, blankRestrictedTools, false, accessAdminNodeIds, false, false); ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).setAddedDirectChildrenFlag(true); if (anyAdded) { collapseEmptyFoldersHelper((DefaultMutableTreeNode) node); } } } @Override protected boolean isForceRebuildOnSelectionChange() { return true; }; @Override protected MarkupContainer newNodeLink(MarkupContainer parent, String id, TreeNode node) { try { parent.add(new AttributeAppender("title", new Model( ((NodeModel) ((DefaultMutableTreeNode) node).getUserObject()).getNode().description), " ")); } catch (Exception e) { log.error(e.getMessage(), e); } return super.newNodeLink(parent, id, node); } }; if (singleRoleOptions) { tree.add(new AttributeAppender("class", new Model("noRoles"), " ")); } form.add(tree); //updateButton button: AjaxButton updateButton = new AjaxButton("update", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form arg1) { try { //save node access and roll information: updateNodeAccess(userId, defaultRole); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.save")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("success.save")); formFeedback2.add(new AttributeModifier("class", true, new Model("success"))); target.addComponent(formFeedback2); } catch (Exception e) { log.error(e.getMessage(), e); formFeedback.setDefaultModel(new ResourceModel("failed.save")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback); formFeedback2.setDefaultModel(new ResourceModel("failed.save")); formFeedback2.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.addComponent(formFeedback2); } //call a js function to hide the message in 5 seconds target.appendJavascript("hideFeedbackTimer('" + formFeedbackId + "');"); target.appendJavascript("hideFeedbackTimer('" + formFeedback2Id + "');"); modifiedAlert = false; } }; form.add(updateButton); //cancelButton button: Button cancelButton = new Button("cancel") { @Override public void onSubmit() { setResponsePage(new SearchUsersPage()); } }; form.add(cancelButton); }
From source file:org.sakaiproject.profile2.tool.components.IconWithClueTip.java
License:Educational Community License
public IconWithClueTip(String id, String iconUrl, IModel textModel) { super(id);/*from w w w .j av a 2s . c o m*/ //tooltip text Label text = new Label("text", textModel); text.setOutputMarkupId(true); add(text); //we need to id of the text span so that we can map it to the link. //the cluetip functions automatically hide it for us. StringBuilder textId = new StringBuilder(); textId.append("#"); textId.append(text.getMarkupId()); //link AjaxFallbackLink link = new AjaxFallbackLink("link") { public void onClick(AjaxRequestTarget target) { //nothing } }; link.add(new AttributeModifier("rel", true, new Model(textId))); link.add(new AttributeModifier("href", true, new Model(textId))); //image ContextImage image = new ContextImage("icon", new Model(iconUrl)); link.add(image); add(link); }
From source file:org.sakaiproject.profile2.tool.components.OnlinePresenceIndicator.java
License:Educational Community License
public OnlinePresenceIndicator(String id, String userUuid) { super(id);//from ww w .j a v a 2s . c om //get user's firstname String firstname = sakaiProxy.getUserFirstName(userUuid); if (StringUtils.isBlank(firstname)) { firstname = new StringResourceModel("profile.name.first.none", null).getString(); } //get user's online status int status = connectionsLogic.getOnlineStatus(userUuid); //get the mapping Map<String, String> m = mapStatus(status); //tooltip text Label text = new Label("text", new StringResourceModel(m.get("text"), null, new Object[] { firstname })); text.setOutputMarkupId(true); add(text); //we need to id of the text span so that we can map it to the link. //the cluetip functions automatically hide it for us. StringBuilder textId = new StringBuilder(); textId.append("#"); textId.append(text.getMarkupId()); //link AjaxFallbackLink link = new AjaxFallbackLink("link") { public void onClick(AjaxRequestTarget target) { //nothing } }; link.add(new AttributeModifier("rel", true, new Model(textId))); link.add(new AttributeModifier("href", true, new Model(textId))); //image ContextImage image = new ContextImage("icon", new Model(m.get("url"))); link.add(image); add(link); }
From source file:org.sakaiproject.profile2.tool.pages.MyPreferences.java
License:Educational Community License
public MyPreferences() { log.debug("MyPreferences()"); disableLink(preferencesLink);/* w w w . j av a 2 s . c om*/ //get current user final String userUuid = sakaiProxy.getCurrentUserId(); //get the prefs record for this user from the database, or a default if none exists yet profilePreferences = preferencesLogic.getPreferencesRecordForUser(userUuid, false); //if null, throw exception if (profilePreferences == null) { throw new ProfilePreferencesNotDefinedException("Couldn't retrieve preferences record for " + userUuid); } //get email address for this user String emailAddress = sakaiProxy.getUserEmail(userUuid); //if no email, set a message into it fo display if (emailAddress == null || emailAddress.length() == 0) { emailAddress = new ResourceModel("preferences.email.none").getObject(); } Label heading = new Label("heading", new ResourceModel("heading.preferences")); add(heading); //feedback for form submit action final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //create model CompoundPropertyModel<ProfilePreferences> preferencesModel = new CompoundPropertyModel<ProfilePreferences>( profilePreferences); //setup form Form<ProfilePreferences> form = new Form<ProfilePreferences>("form", preferencesModel); form.setOutputMarkupId(true); //EMAIL SECTION //email settings form.add(new Label("emailSectionHeading", new ResourceModel("heading.section.email"))); form.add(new Label("emailSectionText", new StringResourceModel("preferences.email.message", null, new Object[] { emailAddress })) .setEscapeModelStrings(false)); //on/off labels form.add(new Label("prefOn", new ResourceModel("preference.option.on"))); form.add(new Label("prefOff", new ResourceModel("preference.option.off"))); //request emails final RadioGroup<Boolean> emailRequests = new RadioGroup<Boolean>("requestEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "requestEmailEnabled")); Radio requestsOn = new Radio<Boolean>("requestsOn", new Model<Boolean>(Boolean.valueOf(true))); requestsOn.setMarkupId("requestsoninput"); requestsOn.setOutputMarkupId(true); emailRequests.add(requestsOn); Radio requestsOff = new Radio<Boolean>("requestsOff", new Model<Boolean>(Boolean.valueOf(false))); requestsOff.setMarkupId("requestsoffinput"); requestsOff.setOutputMarkupId(true); emailRequests.add(requestsOff); emailRequests.add(new Label("requestsLabel", new ResourceModel("preferences.email.requests"))); form.add(emailRequests); //updater emailRequests.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //visibility for request emails emailRequests.setVisible(sakaiProxy.isConnectionsEnabledGlobally()); //confirm emails final RadioGroup<Boolean> emailConfirms = new RadioGroup<Boolean>("confirmEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "confirmEmailEnabled")); Radio confirmsOn = new Radio<Boolean>("confirmsOn", new Model<Boolean>(Boolean.valueOf(true))); confirmsOn.setMarkupId("confirmsoninput"); confirmsOn.setOutputMarkupId(true); emailConfirms.add(confirmsOn); Radio confirmsOff = new Radio<Boolean>("confirmsOff", new Model<Boolean>(Boolean.valueOf(false))); confirmsOff.setMarkupId("confirmsoffinput"); confirmsOff.setOutputMarkupId(true); emailConfirms.add(confirmsOff); emailConfirms.add(new Label("confirmsLabel", new ResourceModel("preferences.email.confirms"))); form.add(emailConfirms); //updater emailConfirms.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //visibility for confirm emails emailConfirms.setVisible(sakaiProxy.isConnectionsEnabledGlobally()); //new message emails final RadioGroup<Boolean> emailNewMessage = new RadioGroup<Boolean>("messageNewEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "messageNewEmailEnabled")); Radio messageNewOn = new Radio<Boolean>("messageNewOn", new Model<Boolean>(Boolean.valueOf(true))); messageNewOn.setMarkupId("messagenewoninput"); messageNewOn.setOutputMarkupId(true); emailNewMessage.add(messageNewOn); Radio messageNewOff = new Radio<Boolean>("messageNewOff", new Model<Boolean>(Boolean.valueOf(false))); messageNewOff.setMarkupId("messagenewoffinput"); messageNewOff.setOutputMarkupId(true); emailNewMessage.add(messageNewOff); emailNewMessage.add(new Label("messageNewLabel", new ResourceModel("preferences.email.message.new"))); form.add(emailNewMessage); //updater emailNewMessage.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); emailNewMessage.setVisible(sakaiProxy.isMessagingEnabledGlobally()); //message reply emails final RadioGroup<Boolean> emailReplyMessage = new RadioGroup<Boolean>("messageReplyEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "messageReplyEmailEnabled")); Radio messageReplyOn = new Radio<Boolean>("messageReplyOn", new Model<Boolean>(Boolean.valueOf(true))); messageReplyOn.setMarkupId("messagereplyoninput"); messageNewOn.setOutputMarkupId(true); emailReplyMessage.add(messageReplyOn); Radio messageReplyOff = new Radio<Boolean>("messageReplyOff", new Model<Boolean>(Boolean.valueOf(false))); messageReplyOff.setMarkupId("messagereplyoffinput"); messageNewOff.setOutputMarkupId(true); emailReplyMessage.add(messageReplyOff); emailReplyMessage.add(new Label("messageReplyLabel", new ResourceModel("preferences.email.message.reply"))); form.add(emailReplyMessage); //updater emailReplyMessage.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); emailReplyMessage.setVisible(sakaiProxy.isMessagingEnabledGlobally()); // new wall item notification emails final RadioGroup<Boolean> wallItemNew = new RadioGroup<Boolean>("wallItemNewEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "wallItemNewEmailEnabled")); Radio wallItemNewOn = new Radio<Boolean>("wallItemNewOn", new Model<Boolean>(Boolean.valueOf(true))); wallItemNewOn.setMarkupId("wallitemnewoninput"); wallItemNewOn.setOutputMarkupId(true); wallItemNew.add(wallItemNewOn); Radio wallItemNewOff = new Radio<Boolean>("wallItemNewOff", new Model<Boolean>(Boolean.valueOf(false))); wallItemNewOff.setMarkupId("wallitemnewoffinput"); wallItemNewOff.setOutputMarkupId(true); wallItemNew.add(wallItemNewOff); wallItemNew.add(new Label("wallItemNewLabel", new ResourceModel("preferences.email.wall.new"))); form.add(wallItemNew); //updater wallItemNew.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //visibility for wall items wallItemNew.setVisible(sakaiProxy.isWallEnabledGlobally()); // added to new worksite emails final RadioGroup<Boolean> worksiteNew = new RadioGroup<Boolean>("worksiteNewEmailEnabled", new PropertyModel<Boolean>(preferencesModel, "worksiteNewEmailEnabled")); Radio worksiteNewOn = new Radio<Boolean>("worksiteNewOn", new Model<Boolean>(Boolean.valueOf(true))); worksiteNewOn.setMarkupId("worksitenewoninput"); worksiteNewOn.setOutputMarkupId(true); worksiteNew.add(worksiteNewOn); Radio worksiteNewOff = new Radio<Boolean>("worksiteNewOff", new Model<Boolean>(Boolean.valueOf(false))); worksiteNewOff.setMarkupId("worksitenewoffinput"); worksiteNewOff.setOutputMarkupId(true); worksiteNew.add(worksiteNewOff); worksiteNew.add(new Label("worksiteNewLabel", new ResourceModel("preferences.email.worksite.new"))); form.add(worksiteNew); //updater worksiteNew.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); // TWITTER SECTION //headings WebMarkupContainer twitterSectionHeadingContainer = new WebMarkupContainer( "twitterSectionHeadingContainer"); twitterSectionHeadingContainer .add(new Label("twitterSectionHeading", new ResourceModel("heading.section.twitter"))); twitterSectionHeadingContainer .add(new Label("twitterSectionText", new ResourceModel("preferences.twitter.message"))); form.add(twitterSectionHeadingContainer); //panel if (sakaiProxy.isTwitterIntegrationEnabledGlobally()) { form.add(new AjaxLazyLoadPanel("twitterPanel") { private static final long serialVersionUID = 1L; @Override public Component getLazyLoadComponent(String markupId) { return new TwitterPrefsPane(markupId, userUuid); } }); } else { form.add(new EmptyPanel("twitterPanel")); twitterSectionHeadingContainer.setVisible(false); } // IMAGE SECTION //only one of these can be selected at a time WebMarkupContainer is = new WebMarkupContainer("imageSettingsContainer"); is.setOutputMarkupId(true); // headings is.add(new Label("imageSettingsHeading", new ResourceModel("heading.section.image"))); is.add(new Label("imageSettingsText", new ResourceModel("preferences.image.message"))); officialImageEnabled = sakaiProxy.isUsingOfficialImageButAlternateSelectionEnabled(); gravatarEnabled = sakaiProxy.isGravatarImageEnabledGlobally(); //official image //checkbox WebMarkupContainer officialImageContainer = new WebMarkupContainer("officialImageContainer"); officialImageContainer .add(new Label("officialImageLabel", new ResourceModel("preferences.image.official"))); officialImage = new CheckBox("officialImage", new PropertyModel<Boolean>(preferencesModel, "useOfficialImage")); officialImage.setMarkupId("officialimageinput"); officialImage.setOutputMarkupId(true); officialImageContainer.add(officialImage); //updater officialImage.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { //set gravatar to false since we can't have both active gravatarImage.setModelObject(false); if (gravatarEnabled) { target.add(gravatarImage); } target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); is.add(officialImageContainer); //if using official images but alternate choice isn't allowed, hide this section if (!officialImageEnabled) { profilePreferences.setUseOfficialImage(false); //set the model false to clear data as well (doesnt really need to do this but we do it to keep things in sync) officialImageContainer.setVisible(false); } //gravatar //checkbox WebMarkupContainer gravatarContainer = new WebMarkupContainer("gravatarContainer"); gravatarContainer.add(new Label("gravatarLabel", new ResourceModel("preferences.image.gravatar"))); gravatarImage = new CheckBox("gravatarImage", new PropertyModel<Boolean>(preferencesModel, "useGravatar")); gravatarImage.setMarkupId("gravatarimageinput"); gravatarImage.setOutputMarkupId(true); gravatarContainer.add(gravatarImage); //updater gravatarImage.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { //set gravatar to false since we can't have both active officialImage.setModelObject(false); if (officialImageEnabled) { target.add(officialImage); } target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); is.add(gravatarContainer); //if gravatar's are disabled, hide this section if (!gravatarEnabled) { profilePreferences.setUseGravatar(false); //set the model false to clear data as well (doesnt really need to do this but we do it to keep things in sync) gravatarContainer.setVisible(false); } //if official image disabled and gravatar disabled, hide the entire container if (!officialImageEnabled && !gravatarEnabled) { is.setVisible(false); } form.add(is); // WIDGET SECTION WebMarkupContainer ws = new WebMarkupContainer("widgetSettingsContainer"); ws.setOutputMarkupId(true); int visibleWidgetCount = 0; //widget settings ws.add(new Label("widgetSettingsHeading", new ResourceModel("heading.section.widget"))); ws.add(new Label("widgetSettingsText", new ResourceModel("preferences.widget.message"))); //kudos WebMarkupContainer kudosContainer = new WebMarkupContainer("kudosContainer"); kudosContainer.add(new Label("kudosLabel", new ResourceModel("preferences.widget.kudos"))); CheckBox kudosSetting = new CheckBox("kudosSetting", new PropertyModel<Boolean>(preferencesModel, "showKudos")); kudosSetting.setMarkupId("kudosinput"); kudosSetting.setOutputMarkupId(true); kudosContainer.add(kudosSetting); //tooltip kudosContainer.add(new IconWithClueTip("kudosToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("preferences.widget.kudos.tooltip"))); //updater kudosSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); ws.add(kudosContainer); if (sakaiProxy.isMyKudosEnabledGlobally()) { visibleWidgetCount++; } else { kudosContainer.setVisible(false); } //gallery feed WebMarkupContainer galleryFeedContainer = new WebMarkupContainer("galleryFeedContainer"); galleryFeedContainer.add(new Label("galleryFeedLabel", new ResourceModel("preferences.widget.gallery"))); CheckBox galleryFeedSetting = new CheckBox("galleryFeedSetting", new PropertyModel<Boolean>(preferencesModel, "showGalleryFeed")); galleryFeedSetting.setMarkupId("galleryfeedsettinginput"); galleryFeedSetting.setOutputMarkupId(true); galleryFeedContainer.add(galleryFeedSetting); //tooltip galleryFeedContainer.add(new IconWithClueTip("galleryFeedToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("preferences.widget.gallery.tooltip"))); //updater galleryFeedSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); ws.add(galleryFeedContainer); if (sakaiProxy.isProfileGalleryEnabledGlobally()) { visibleWidgetCount++; } else { galleryFeedContainer.setVisible(false); } //online status WebMarkupContainer onlineStatusContainer = new WebMarkupContainer("onlineStatusContainer"); onlineStatusContainer .add(new Label("onlineStatusLabel", new ResourceModel("preferences.widget.onlinestatus"))); CheckBox onlineStatusSetting = new CheckBox("onlineStatusSetting", new PropertyModel<Boolean>(preferencesModel, "showOnlineStatus")); onlineStatusSetting.setMarkupId("onlinestatussettinginput"); onlineStatusSetting.setOutputMarkupId(true); onlineStatusContainer.add(onlineStatusSetting); //tooltip onlineStatusContainer.add(new IconWithClueTip("onlineStatusToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("preferences.widget.onlinestatus.tooltip"))); //updater onlineStatusSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); ws.add(onlineStatusContainer); if (sakaiProxy.isOnlineStatusEnabledGlobally()) { visibleWidgetCount++; } else { onlineStatusContainer.setVisible(false); } // Hide widget container if nothing to show if (visibleWidgetCount == 0) { ws.setVisible(false); } form.add(ws); //submit button IndicatingAjaxButton submitButton = new IndicatingAjaxButton("submit", form) { private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, Form<?> form) { //get the backing model ProfilePreferences profilePreferences = (ProfilePreferences) form.getModelObject(); formFeedback.setDefaultModel(new ResourceModel("success.preferences.save.ok")); formFeedback.add(new AttributeModifier("class", true, new Model<String>("success"))); //save if (preferencesLogic.savePreferencesRecord(profilePreferences)) { formFeedback.setDefaultModel(new ResourceModel("success.preferences.save.ok")); formFeedback.add(new AttributeModifier("class", true, new Model<String>("success"))); //post update event sakaiProxy.postEvent(ProfileConstants.EVENT_PREFERENCES_UPDATE, "/profile/" + userUuid, true); } else { formFeedback.setDefaultModel(new ResourceModel("error.preferences.save.failed")); formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage"))); } //resize iframe target.appendJavaScript("setMainFrameHeight(window.name);"); //PRFL-775 - set focus to feedback message so it is announced to screenreaders target.appendJavaScript("$('#" + formFeedbackId + "').focus();"); target.add(formFeedback); } }; submitButton.setModel(new ResourceModel("button.save.settings")); submitButton.setDefaultFormProcessing(false); form.add(submitButton); add(form); }
From source file:org.sakaiproject.profile2.tool.pages.MyPrivacy.java
License:Educational Community License
public MyPrivacy() { log.debug("MyPrivacy()"); disableLink(myPrivacyLink);/*from ww w . j a v a 2 s. c o m*/ //get current user final String userUuid = sakaiProxy.getCurrentUserId(); //get the privacy record for this user from the database, or a default if none exists profilePrivacy = privacyLogic.getPrivacyRecordForUser(userUuid, false); //if null, throw exception if (profilePrivacy == null) { throw new ProfilePrivacyNotDefinedException("Couldn't retrieve privacy record for " + userUuid); } Label heading = new Label("heading", new ResourceModel("heading.privacy")); add(heading); Label infoLocked = new Label("infoLocked"); infoLocked.setOutputMarkupPlaceholderTag(true); infoLocked.setVisible(false); add(infoLocked); //feedback for form submit action final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //create model CompoundPropertyModel<ProfilePrivacy> privacyModel = new CompoundPropertyModel<ProfilePrivacy>( profilePrivacy); //setup form Form<ProfilePrivacy> form = new Form<ProfilePrivacy>("form", privacyModel); form.setOutputMarkupId(true); //setup LinkedHashMap of privacy options for strict things final LinkedHashMap<Integer, String> privacySettingsStrict = new LinkedHashMap<Integer, String>(); privacySettingsStrict.put(ProfileConstants.PRIVACY_OPTION_EVERYONE, new StringResourceModel("privacy.option.everyone", this, null).getString()); privacySettingsStrict.put(ProfileConstants.PRIVACY_OPTION_ONLYFRIENDS, new StringResourceModel("privacy.option.onlyfriends", this, null).getString()); privacySettingsStrict.put(ProfileConstants.PRIVACY_OPTION_ONLYME, new StringResourceModel("privacy.option.onlyme", this, null).getString()); //model that wraps our options IModel dropDownModelStrict = new Model() { public ArrayList<Integer> getObject() { return new ArrayList(privacySettingsStrict.keySet()); } }; //setup LinkedHashMap of privacy options for more relaxed things final LinkedHashMap<Integer, String> privacySettingsRelaxed = new LinkedHashMap<Integer, String>(); privacySettingsRelaxed.put(ProfileConstants.PRIVACY_OPTION_EVERYONE, new StringResourceModel("privacy.option.everyone", this, null).getString()); privacySettingsRelaxed.put(ProfileConstants.PRIVACY_OPTION_ONLYFRIENDS, new StringResourceModel("privacy.option.onlyfriends", this, null).getString()); //model that wraps our options IModel dropDownModelRelaxed = new Model() { public ArrayList<Integer> getObject() { return new ArrayList(privacySettingsRelaxed.keySet()); } }; //setup LinkedHashMap of privacy options for super duper strict things! final LinkedHashMap<Integer, String> privacySettingsSuperStrict = new LinkedHashMap<Integer, String>(); privacySettingsSuperStrict.put(ProfileConstants.PRIVACY_OPTION_ONLYFRIENDS, new StringResourceModel("privacy.option.onlyfriends", this, null).getString()); privacySettingsSuperStrict.put(ProfileConstants.PRIVACY_OPTION_NOBODY, new StringResourceModel("privacy.option.nobody", this, null).getString()); //model that wraps our options IModel dropDownModelSuperStrict = new Model() { public ArrayList<Integer> getObject() { return new ArrayList(privacySettingsSuperStrict.keySet()); } }; //when using DDC with a compoundPropertyModel we use this constructor: DDC<T>(String,IModel<List<T>>,IChoiceRenderer<T>) //and the ID of the DDC field maps to the field in the CompoundPropertyModel //the AjaxFormComponentUpdatingBehavior is to allow the DDC and checkboxes to fadeaway any error/success message //that might be visible since the form has changed and it needs to be submitted again for it to take effect //profile image privacy WebMarkupContainer profileImageContainer = new WebMarkupContainer("profileImageContainer"); profileImageContainer.add(new Label("profileImageLabel", new ResourceModel("privacy.profileimage"))); DropDownChoice profileImageChoice = new DropDownChoice("profileImage", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); profileImageChoice.setMarkupId("imageprivacyinput"); profileImageChoice.setOutputMarkupId(true); profileImageContainer.add(profileImageChoice); //tooltip profileImageContainer.add(new IconWithClueTip("profileImageToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.profileimage.tooltip"))); form.add(profileImageContainer); //updater profileImageChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //basicInfo privacy WebMarkupContainer basicInfoContainer = new WebMarkupContainer("basicInfoContainer"); basicInfoContainer.add(new Label("basicInfoLabel", new ResourceModel("privacy.basicinfo"))); DropDownChoice basicInfoChoice = new DropDownChoice("basicInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); basicInfoChoice.setMarkupId("basicinfoprivacyinput"); basicInfoChoice.setOutputMarkupId(true); basicInfoContainer.add(basicInfoChoice); //tooltip basicInfoContainer.add(new IconWithClueTip("basicInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.basicinfo.tooltip"))); form.add(basicInfoContainer); //updater basicInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //contactInfo privacy WebMarkupContainer contactInfoContainer = new WebMarkupContainer("contactInfoContainer"); contactInfoContainer.add(new Label("contactInfoLabel", new ResourceModel("privacy.contactinfo"))); DropDownChoice contactInfoChoice = new DropDownChoice("contactInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); contactInfoChoice.setMarkupId("contactinfoprivacyinput"); contactInfoChoice.setOutputMarkupId(true); contactInfoContainer.add(contactInfoChoice); //tooltip contactInfoContainer.add(new IconWithClueTip("contactInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.contactinfo.tooltip"))); form.add(contactInfoContainer); //updater contactInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //staffInfo privacy WebMarkupContainer staffInfoContainer = new WebMarkupContainer("staffInfoContainer"); staffInfoContainer.add(new Label("staffInfoLabel", new ResourceModel("privacy.staffinfo"))); DropDownChoice staffInfoChoice = new DropDownChoice("staffInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); staffInfoChoice.setMarkupId("staffinfoprivacyinput"); staffInfoChoice.setOutputMarkupId(true); staffInfoContainer.add(staffInfoChoice); //tooltip staffInfoContainer.add(new IconWithClueTip("staffInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.staff.tooltip"))); form.add(staffInfoContainer); //updater staffInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //studentInfo privacy WebMarkupContainer studentInfoContainer = new WebMarkupContainer("studentInfoContainer"); studentInfoContainer.add(new Label("studentInfoLabel", new ResourceModel("privacy.studentinfo"))); DropDownChoice studentInfoChoice = new DropDownChoice("studentInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); studentInfoChoice.setMarkupId("studentinfoprivacyinput"); studentInfoChoice.setOutputMarkupId(true); studentInfoContainer.add(studentInfoChoice); //tooltip studentInfoContainer.add(new IconWithClueTip("studentInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.student.tooltip"))); form.add(studentInfoContainer); //updater studentInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //businesInfo privacy WebMarkupContainer businessInfoContainer = new WebMarkupContainer("businessInfoContainer"); businessInfoContainer.add(new Label("businessInfoLabel", new ResourceModel("privacy.businessinfo"))); DropDownChoice businessInfoChoice = new DropDownChoice("businessInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); businessInfoChoice.setMarkupId("businessinfoprivacyinput"); businessInfoChoice.setOutputMarkupId(true); businessInfoContainer.add(businessInfoChoice); //tooltip businessInfoContainer.add(new IconWithClueTip("businessInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.businessinfo.tooltip"))); form.add(businessInfoContainer); //updater businessInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); businessInfoContainer.setVisible(sakaiProxy.isBusinessProfileEnabled()); //socialNetworkingInfo privacy WebMarkupContainer socialNetworkingInfoContainer = new WebMarkupContainer("socialNetworkingInfoContainer"); socialNetworkingInfoContainer .add(new Label("socialNetworkingInfoLabel", new ResourceModel("privacy.socialinfo"))); DropDownChoice socialNetworkingInfoChoice = new DropDownChoice("socialNetworkingInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); socialNetworkingInfoChoice.setMarkupId("socialinfoprivacyinput"); socialNetworkingInfoChoice.setOutputMarkupId(true); socialNetworkingInfoContainer.add(socialNetworkingInfoChoice); //tooltip socialNetworkingInfoContainer.add(new IconWithClueTip("socialNetworkingInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.socialinfo.tooltip"))); form.add(socialNetworkingInfoContainer); //updater socialNetworkingInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //personalInfo privacy WebMarkupContainer personalInfoContainer = new WebMarkupContainer("personalInfoContainer"); personalInfoContainer.add(new Label("personalInfoLabel", new ResourceModel("privacy.personalinfo"))); DropDownChoice personalInfoChoice = new DropDownChoice("personalInfo", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); personalInfoChoice.setMarkupId("personalinfoprivacyinput"); personalInfoChoice.setOutputMarkupId(true); personalInfoContainer.add(personalInfoChoice); //tooltip personalInfoContainer.add(new IconWithClueTip("personalInfoToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.personalinfo.tooltip"))); form.add(personalInfoContainer); //updater personalInfoChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //birthYear privacy WebMarkupContainer birthYearContainer = new WebMarkupContainer("birthYearContainer"); birthYearContainer.add(new Label("birthYearLabel", new ResourceModel("privacy.birthyear"))); CheckBox birthYearCheckbox = new CheckBox("birthYear", new PropertyModel(privacyModel, "showBirthYear")); birthYearCheckbox.setMarkupId("birthyearprivacyinput"); birthYearCheckbox.setOutputMarkupId(true); birthYearContainer.add(birthYearCheckbox); //tooltip birthYearContainer.add(new IconWithClueTip("birthYearToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.birthyear.tooltip"))); form.add(birthYearContainer); //updater birthYearCheckbox.add(new AjaxFormComponentUpdatingBehavior("onclick") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); //myFriends privacy WebMarkupContainer myFriendsContainer = new WebMarkupContainer("myFriendsContainer"); myFriendsContainer.add(new Label("myFriendsLabel", new ResourceModel("privacy.myfriends"))); DropDownChoice myFriendsChoice = new DropDownChoice("myFriends", dropDownModelStrict, new HashMapChoiceRenderer(privacySettingsStrict)); myFriendsChoice.setMarkupId("friendsprivacyinput"); myFriendsChoice.setOutputMarkupId(true); myFriendsContainer.add(myFriendsChoice); //tooltip myFriendsContainer.add(new IconWithClueTip("myFriendsToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.myfriends.tooltip"))); form.add(myFriendsContainer); //updater myFriendsChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); myFriendsContainer.setVisible(sakaiProxy.isConnectionsEnabledGlobally()); //myStatus privacy WebMarkupContainer myStatusContainer = new WebMarkupContainer("myStatusContainer"); myStatusContainer.add(new Label("myStatusLabel", new ResourceModel("privacy.mystatus"))); DropDownChoice myStatusChoice = new DropDownChoice("myStatus", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); myStatusChoice.setMarkupId("statusprivacyinput"); myStatusChoice.setOutputMarkupId(true); myStatusContainer.add(myStatusChoice); //tooltip myStatusContainer.add(new IconWithClueTip("myStatusToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.mystatus.tooltip"))); form.add(myStatusContainer); //updater myStatusChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); myStatusContainer.setVisible(sakaiProxy.isProfileStatusEnabled()); // gallery privacy WebMarkupContainer myPicturesContainer = new WebMarkupContainer("myPicturesContainer"); myPicturesContainer.add(new Label("myPicturesLabel", new ResourceModel("privacy.mypictures"))); DropDownChoice myPicturesChoice = new DropDownChoice("myPictures", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); myPicturesChoice.setMarkupId("picturesprivacyinput"); myPicturesChoice.setOutputMarkupId(true); myPicturesContainer.add(myPicturesChoice); myPicturesContainer.add(new IconWithClueTip("myPicturesToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.mypictures.tooltip"))); form.add(myPicturesContainer); myPicturesChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); myPicturesContainer.setVisible(sakaiProxy.isProfileGalleryEnabledGlobally()); // messages privacy WebMarkupContainer messagesContainer = new WebMarkupContainer("messagesContainer"); messagesContainer.add(new Label("messagesLabel", new ResourceModel("privacy.messages"))); DropDownChoice messagesChoice = new DropDownChoice("messages", dropDownModelSuperStrict, new HashMapChoiceRenderer(privacySettingsSuperStrict)); messagesChoice.setMarkupId("messagesprivacyinput"); messagesChoice.setOutputMarkupId(true); messagesContainer.add(messagesChoice); messagesContainer.add(new IconWithClueTip("messagesToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.messages.tooltip"))); form.add(messagesContainer); messagesChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); messagesContainer.setVisible(sakaiProxy.isMessagingEnabledGlobally()); // kudos privacy WebMarkupContainer myKudosContainer = new WebMarkupContainer("myKudosContainer"); myKudosContainer.add(new Label("myKudosLabel", new ResourceModel("privacy.mykudos"))); DropDownChoice kudosChoice = new DropDownChoice("myKudos", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); kudosChoice.setMarkupId("kudosprivacyinput"); kudosChoice.setOutputMarkupId(true); myKudosContainer.add(kudosChoice); myKudosContainer.add(new IconWithClueTip("myKudosToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.mykudos.tooltip"))); form.add(myKudosContainer); kudosChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); myKudosContainer.setVisible(sakaiProxy.isMyKudosEnabledGlobally()); // wall privacy WebMarkupContainer myWallContainer = new WebMarkupContainer("myWallContainer"); myWallContainer.add(new Label("myWallLabel", new ResourceModel("privacy.mywall"))); DropDownChoice myWallChoice = new DropDownChoice("myWall", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); myWallChoice.setMarkupId("wallprivacyinput"); myWallChoice.setOutputMarkupId(true); myWallContainer.add(myWallChoice); myWallContainer.add(new IconWithClueTip("myWallToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.mywall.tooltip"))); form.add(myWallContainer); myWallChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); myWallContainer.setVisible(sakaiProxy.isWallEnabledGlobally()); // online status privacy WebMarkupContainer onlineStatusContainer = new WebMarkupContainer("onlineStatusContainer"); onlineStatusContainer.add(new Label("onlineStatusLabel", new ResourceModel("privacy.onlinestatus"))); DropDownChoice onlineStatusChoice = new DropDownChoice("onlineStatus", dropDownModelRelaxed, new HashMapChoiceRenderer(privacySettingsRelaxed)); onlineStatusChoice.setMarkupId("onlinestatusprivacyinput"); onlineStatusChoice.setOutputMarkupId(true); onlineStatusContainer.add(onlineStatusChoice); onlineStatusContainer.add(new IconWithClueTip("onlineStatusToolTip", ProfileConstants.INFO_IMAGE, new ResourceModel("text.privacy.onlinestatus.tooltip"))); form.add(onlineStatusContainer); onlineStatusChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();"); } }); onlineStatusContainer.setVisible(sakaiProxy.isOnlineStatusEnabledGlobally()); //submit button IndicatingAjaxButton submitButton = new IndicatingAjaxButton("submit", form) { protected void onSubmit(AjaxRequestTarget target, Form form) { //save() form, show feedback. perhaps redirect back to main page after a short while? if (save(form)) { formFeedback.setDefaultModel(new ResourceModel("success.privacy.save.ok")); formFeedback.add(new AttributeModifier("class", true, new Model<String>("success"))); //post update event sakaiProxy.postEvent(ProfileConstants.EVENT_PRIVACY_UPDATE, "/profile/" + userUuid, true); } else { formFeedback.setDefaultModel(new ResourceModel("error.privacy.save.failed")); formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage"))); } //resize iframe target.appendJavaScript("setMainFrameHeight(window.name);"); //PRFL-775 - set focus to feedback message so it is announced to screenreaders target.appendJavaScript("$('#" + formFeedbackId + "').focus();"); target.add(formFeedback); } }; submitButton.setModel(new ResourceModel("button.save.settings")); submitButton.setOutputMarkupId(true); form.add(submitButton); //cancel button /* AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"), form) { protected void onSubmit(AjaxRequestTarget target, Form form) { setResponsePage(new MyProfile()); } }; cancelButton.setDefaultFormProcessing(false); form.add(cancelButton); */ if (!sakaiProxy.isPrivacyChangeAllowedGlobally()) { infoLocked.setDefaultModel(new ResourceModel("text.privacy.cannot.modify")); infoLocked.setVisible(true); profileImageChoice.setEnabled(false); basicInfoChoice.setEnabled(false); contactInfoChoice.setEnabled(false); studentInfoChoice.setEnabled(false); businessInfoChoice.setEnabled(false); personalInfoChoice.setEnabled(false); birthYearCheckbox.setEnabled(false); myFriendsChoice.setEnabled(false); myStatusChoice.setEnabled(false); myPicturesChoice.setEnabled(false); messagesChoice.setEnabled(false); myWallChoice.setEnabled(false); onlineStatusChoice.setEnabled(false); submitButton.setEnabled(false); submitButton.setVisible(false); form.setEnabled(false); } add(form); }