Java Code Examples for org.apache.wicket.markup.html.form.TextField.setMarkupId()

The following are Jave code examples for showing how to use setMarkupId() of the org.apache.wicket.markup.html.form.TextField class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: artifactory   File: LoginPanel.java   Source Code and License Vote up 4 votes
public LoginPanel(String string, Form form) {
    super(string);

    Label defaultCredentialsLabel = new Label("defaultCredentials", " (default: admin/password)");
    try {
        UserInfo userInfo = userGroupService.findUser("admin");
        defaultCredentialsLabel.setVisible(neverLoggedIn(userInfo) && defaultAdminPassword(userInfo));
    } catch (Exception ignored) {
        defaultCredentialsLabel.setVisible(false);
    }
    add(defaultCredentialsLabel);

    // add username
    TextField username = new TextField("username");
    username.setRequired(true);
    username.setMarkupId("username");
    username.setOutputMarkupId(true);
    username.add(new AttributeModifier("autocomplete", new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            return ConstantValues.useUserNameAutoCompleteOnLogin.getString();
        }
    }));

    add(username);

    // add password
    PasswordTextField password = new PasswordTextField("password");
    password.setRequired(false);
    password.setMarkupId("password");
    password.setOutputMarkupId(true);
    add(password);

    // add login link
    TitledPageLink ssoLoginLink = new TitledPageLink("ssoLogin", "SSO Login", null) {
        @Override
        protected CharSequence getURL() {
            return addons.addonByType(SamlAddon.class).getSamlLoginIdentityProviderUrl();
        }

        @Override
        public boolean isEnabled() {
            return addons.addonByType(SamlAddon.class).isSamlEnabled();
        }

        @Override
        public boolean isVisible() {
            return addons.addonByType(SamlAddon.class).isSamlEnabled();
        }
    };
    add(ssoLoginLink);
    // add login link
    IFormSubmittingComponent loginLink =
            addons.addonByType(WebApplicationAddon.class).getLoginLink("loginLink", form);
    addDefaultButton(loginLink);


    // add remember me checkbox
    StyledCheckbox checkbox = new StyledCheckbox("rememberMe") {
        @Override
        protected String getCheckboxInputName(String defaultName) {
            // set the parameter name to springs' remember me filter default name
            return AbstractRememberMeServices.DEFAULT_PARAMETER;
        }
    };
    checkbox.setSubmitButton((Component) loginLink);
    checkbox.setOutputMarkupPlaceholderTag(true);
    checkbox.setVisible(!ConstantValues.securityDisableRememberMe.getBoolean());
    add(checkbox);

    // add cancel link
    addButton(new TitledPageLink("cancel", "Cancel", ArtifactoryApplication.get().getHomePage()));

    // add forgot password link
    if (isMailServerConfigured()) {
        addButton(new ForgotPasswordLink("forgotPassword"));
    }
}
 
Example 2
Project: sakai   File: EditablePanelDate.java   Source Code and License Vote up 4 votes
public EditablePanelDate(String id, IModel inputModel, final NodeModel nodeModel, final TreeNode node, final boolean startDate)
{
	super(id);

	if (startDate && nodeModel.getNodeShoppingPeriodStartDate() != null) {
		dateTextField = DateFormatterUtil.format(nodeModel.getNodeShoppingPeriodStartDate(), DATEPICKER_FORMAT, getSession().getLocale());
	}
	if (!startDate && nodeModel.getShoppingPeriodEndDate() != null) {
		dateTextField = DateFormatterUtil.format(nodeModel.getNodeShoppingPeriodEndDate(), DATEPICKER_FORMAT, getSession().getLocale());
	}

	final TextField date = new TextField<String>("dateTextField", new PropertyModel<String>(this, "dateTextField")){
		@Override
		public boolean isVisible() {
			return nodeModel.isDirectAccess() && nodeModel.getNodeShoppingPeriodAdmin();
		}
		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			tag.append("size", "8", "");
			tag.append("readonly", "readonly", "");
			tag.append("class", "formInputField", " ");
			tag.append("class", "datePicker", " ");
		}
	};
	String dateInputId = ((startDate) ? "dateTextFieldStart_" : "dateTextFieldEnd_") + nodeModel.getNodeId();
	date.setMarkupId(dateInputId);

	final HiddenField hiddenInput = new HiddenField<String>("hiddenDateTextField", new PropertyModel<String>(this, "hiddenDateTextField"));
	String hiddenInputId = String.format((startDate) ? HIDDEN_START_ISO8601 : HIDDEN_END_ISO8601, nodeModel.getNodeId());
	hiddenInput.setMarkupId(hiddenInputId);
	hiddenInput.add(new AjaxFormComponentUpdatingBehavior("onchange")
	{
		@Override
		protected void onUpdate(AjaxRequestTarget target)
		{
			if (DateFormatterUtil.isValidISODate(hiddenDateTextField) && hiddenDateTextField != null){
				Date hiddenDate = DateFormatterUtil.parseISODate(hiddenDateTextField);
				if(startDate){
					nodeModel.setShoppingPeriodStartDate(hiddenDate);
					dateTextField = DateFormatterUtil.format(hiddenDate, DATEPICKER_FORMAT, getSession().getLocale());
				}else{
					nodeModel.setShoppingPeriodEndDate(hiddenDate);
					dateTextField = DateFormatterUtil.format(hiddenDate, DATEPICKER_FORMAT, getSession().getLocale());
				}

				//In order for the models to refresh, you have to call "expand" or "collapse" then "updateTree",
				//since I don't want to expand or collapse, I just call whichever one the node is already
				//Refreshing the tree will update all the models and information (like role) will be generated onClick
				if(((BaseTreePage)target.getPage()).getTree().getTreeState().isNodeExpanded(node)){
					((BaseTreePage)target.getPage()).getTree().getTreeState().expandNode(node);
				}else{
					((BaseTreePage)target.getPage()).getTree().getTreeState().collapseNode(node);
				}
				((BaseTreePage)target.getPage()).getTree().updateTree(target);
				target.focusComponent(hiddenInput);
			}
		}

	});
	add(date);
	add(hiddenInput);
}