Example usage for org.apache.wicket Component setVisible

List of usage examples for org.apache.wicket Component setVisible

Introduction

In this page you can find the example usage for org.apache.wicket Component setVisible.

Prototype

public final Component setVisible(final boolean visible) 

Source Link

Document

Sets whether this component and any children are visible.

Usage

From source file:com.servoy.j2db.server.headlessclient.dataui.WebBaseSelectBox.java

License:Open Source License

public void setText(String txt) {
    this.text = txt;
    Component c = get("text_" + getId()); //$NON-NLS-1$
    if (txt == null || txt.trim().length() == 0) {
        c.setVisible(false);
    } else {/*from ww  w  . ja  va2 s .co  m*/
        c.setDefaultModelObject(txt);
        c.setVisible(true);
        c.setEscapeModelStrings(false);
    }
}

From source file:com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.java

License:Open Source License

private void updateHeader(Component columnHeader, Component columnIdentifier) {
    columnHeader.setVisible(columnIdentifier.isVisible());
    columnHeader.setEnabled(isEnabled());
    if (columnHeader instanceof MarkupContainer)
        enableChildrenInContainer((MarkupContainer) columnHeader, isEnabled());
}

From source file:com.tysanclan.site.projectewok.pages.member.CreateGamePetitionPage.java

License:Open Source License

public CreateGamePetitionPage() {
    super("Create Game Petition");

    add(new Label("count", new Model<Integer>(gameService.getRequiredPetitionSignatures())));

    Form<GamePetition> form = new Form<GamePetition>("petitionForm") {
        private static final long serialVersionUID = 1L;

        /**//from  w w w . j ava  2s . co  m
         * @see org.apache.wicket.markup.html.form.Form#onSubmit()
         */
        @SuppressWarnings("unchecked")
        @Override
        protected void onSubmit() {
            FileUploadField iconField = (FileUploadField) get("icon");
            FileUpload upload = iconField.getFileUpload();

            TextField<String> nameField = (TextField<String>) get("name");
            DropDownChoice<Realm> realmChoice = (DropDownChoice<Realm>) get("realm");
            TextField<String> realmField = (TextField<String>) get("newRealm");

            String name = nameField.getModelObject();
            Realm realm = realmChoice.getModelObject();
            String realmName = realmField.getModelObject();

            GamePetition p = null;

            if (realm == null) {
                p = gameService.createPetition(getUser(), name, realmName, upload.getBytes());
            } else {
                p = gameService.createPetition(getUser(), name, realm, upload.getBytes());
            }

            if (p != null) {

                setResponsePage(new SignGamePetitionsPage());
            } else {
                error("Invalid image size, did you upload a valid GIF, JPEG or PNG with dimensions at least 48x48 and at most 64x64?");
            }
        }

    };

    form.setMultiPart(true);

    add(form);

    form.add(new TextField<String>("name", new Model<String>("")).setRequired(true));
    form.add(new FileUploadField("icon").setRequired(true));

    List<Realm> realms = realmService.getRealms();

    DropDownChoice<Realm> realmChoice = new DropDownChoice<Realm>("realm", ModelMaker.wrap((Realm) null),
            ModelMaker.wrapChoices(realms));
    realmChoice.setNullValid(true);
    realmChoice.setVisible(realms.size() > 0);
    realmChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            DropDownChoice<Realm> rc = (DropDownChoice<Realm>) getComponent();
            Component newRealmField = rc.getParent().get("newRealm");
            newRealmField.setVisible(rc.getModelObject() == null);
            if (target != null) {
                target.add(newRealmField);
            }

        }
    });
    realmChoice.setChoiceRenderer(new IChoiceRenderer<Realm>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Realm object) {
            return object.getName();
        }

        @Override
        public String getIdValue(Realm object, int index) {
            return object == null ? "null" : object.getId().toString();
        }

    });

    form.add(new TextField<String>("newRealm", new Model<String>("")).setOutputMarkupId(true)
            .setOutputMarkupPlaceholderTag(true));

    form.add(realmChoice);

}

From source file:com.userweave.pages.configuration.DisableComponentIfStudyStateNotInitVisitor.java

License:Open Source License

private void disable(Component component) {
    if (HIDE) {//from www .j  ava 2s .  c  o m
        component.setVisible(false);
    } else {
        component.setEnabled(false);
    }
}

From source file:de.codepitbull.wiquery.HomePage.java

License:Apache License

private Component createTabs(String wicketId) {
    final WebMarkupContainer conatiner = new WebMarkupContainer("tabs");
    final Tabs tabs = new Tabs("tabs");
    tabs.add(new Label("default", "Content"));
    conatiner.add(new WebMarkupContainer("hidden").setOutputMarkupId(true).setVisible(false));
    conatiner.add(new AjaxLink<Void>("add") {
        @Override/*from  w  w w.  j  av a2  s .co  m*/
        public void onClick(AjaxRequestTarget target) {
            Component component = conatiner.get("hidden");
            component.setVisible(true);
            target.add(component);
            tabs.add(target, 1, "Content", component);
        }
    });
    conatiner.add(tabs);
    return conatiner;
}

From source file:de.flapdoodle.wicket.behavior.VisibilityBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);

    Boolean visible = _model.getObject();
    component.setVisible(visible != null ? visible : false);
}

From source file:gr.interamerican.wicket.factories.LinkFactory.java

License:Open Source License

/**
 * Creates an AjaxLink that togles on/of the visibility of a component.
 * //from   w w w .  jav  a  2  s .  co m
 * The Component must have <code>outputMarkUpPlaceholderId = true</code>.
 * 
 * @param componentName
 *        Name of the panel who's visibility is toggled on/off.
 * @param <T>
 *        Type of link model object.          
 *        
 * @param container - O container that contains the component and the link.
 * 
 * @return Returns the link.  
 */

public static <T> AjaxLink<T> createTogleVisibleLink(final String componentName,
        final MarkupContainer container) {
    AjaxLink<T> refreshLink = new AjaxLink<T>(componentName + "Link") { //$NON-NLS-1$

        /**
         * serialize.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Component component = container.get(componentName);
            boolean newVisibility = !component.isVisible();
            component.setVisible(newVisibility);
            target.add(component);
        }
    };
    return refreshLink;

}

From source file:gr.interamerican.wicket.utils.WicketUtils.java

License:Open Source License

/**
 * Sets the visible property on a number of wicket components.
 * //from   w  ww.  j  a v a2  s .c  o m
 * @param visible
 * @param components
 */
public static void setVisible(boolean visible, Component... components) {
    for (Component cmp : components) {
        if (cmp != null) {
            cmp.setVisible(visible);
        }
    }
}

From source file:jp.go.nict.langrid.management.web.view.page.language.component.form.panel.AbstractLanguagePathPanel.java

License:Open Source License

public void switchVisible() {
    for (Component c : switchVisibleList) {
        c.setVisible(!c.isVisible());
    }
}

From source file:jp.go.nict.langrid.management.web.view.page.language.component.form.panel.AbstractLanguagePathPanel.java

License:Open Source License

public void setAllVisibled() {
    for (Component c : switchVisibleList) {
        c.setVisible(true);
    }
}