Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.cantaa.util.wicket.behaviors;
Sets the visibility of the attached component only by CSS (i.e. display:none), controlled by the Boolean Model

Hans Lesmeister
public class ShowHideBehavior extends JQueryBehavior {
    private IModel<BooleanvisibilityModel;
    private final boolean negate;
    public ShowHideBehavior(IModel<BooleanvisibilityModel) {


visibilityModel The model that controls the visibility of the attached component
negate false (def.): the component's visibility is set according the model, i.e. if the model is true, then visibility is set to true as well. If negate = true then the opposite happens: if the model is true then the visibility of the component is set to false
    public ShowHideBehavior(IModel<BooleanvisibilityModelboolean negate) {
        this. = visibilityModel;
        this. = negate;
    public boolean isEnabled(Component component) {
        return ( != null);
    public void onConfigure(Component component) {
        if ( != null) {
            JQuery jq;
            if () {
                jq = JQuery.$(component).showHide(!.getObject());
            } else {
                jq = JQuery.$(component).showHide(.getObject());
New to GrepCode? Check out our FAQ X