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

Author(s):
Hans Lesmeister
public class ShowHideBehavior extends JQueryBehavior {
    private IModel<BooleanvisibilityModel;
    private final boolean negate;
    public ShowHideBehavior(IModel<BooleanvisibilityModel) {
        this(visibilityModelfalse);
    }

    
Constructor

Parameters:
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) {
        super();
        this. = visibilityModel;
        this. = negate;
    }
    @Override
    public boolean isEnabled(Component component) {
        return ( != null);
    }
    @Override
    public void onConfigure(Component component) {
        super.onConfigure(component);
        if ( != null) {
            JQuery jq;
            if () {
                jq = JQuery.$(component).showHide(!.getObject());
            } else {
                jq = JQuery.$(component).showHide(.getObject());
            }
            setJQuery(jq);
        }
    }
New to GrepCode? Check out our FAQ X