You are right, but the problem is the panel that is not really a panel as I say but a container .. so I cannot switch with an empty panel.

Anyway I don't think is a bad idea to have a display attribute for Component, for now I've solved using the following class.


public class HideableContainer extends WebMarkupContainer {

    private boolean display;
   
    public HideableContainer(String id) {
        this(id,null);
    }
   
    public HideableContainer(String id, IModel model) {
        super(id, model);
        add( new AttributeModifier("style", true, new AbstractReadOnlyModel() {

            public Object getObject(Component component) {
                return display ? "" : "display: none";
            }
           
        } ) );
    }

    public boolean getDisplay() {
        return display;
    }

    public void setDisplay(boolean display) {
        this.display = display;
    }   
}

Thanks.

- Paolo



On 7/21/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
i dont think what you are thinking about is a very clean solution.

if you want to avoid an extra container do this:

instead of initially adding the component and setting visible to false add an EmptyPanel, then instead of making your component visible create an instance and replace the panel with it.

no extra container and no component until its really needed, best of both worlds


-Igor


On 7/20/06, Paolo Di Tommaso < [EMAIL PROTECTED]> wrote:
I was supposing that but I would like to have a simpler structure avoiding to add unuseful container.

My idea is to hide the component using a simple css class or style display: none.

I think it should possible using an AttributeModifier but I don't know how to override the default visibility mechanism.

Any suggestion would be appreciated.

Thanks.

- Paolo



On 7/20/06, Igor Vaynberg <[EMAIL PROTECTED] > wrote:
the problem is that if the panel is hidden initially it doesnt have its div/span tag with an id attribute in the markup, so the ajax request cannot find the tag to redraw.

in situations like this you have to wrap the panel in a webmarkupcontainer, call setoutputmarkupid(true) on it, and target that container in your ajax target.

that way the container will be drawn initially empty : <span id="container"></span> and when you make your panel visible it will contain the panel <span id="container"><span id="panel">....</span></span>

-Igor


On 7/20/06, Paolo Di Tommaso < [EMAIL PROTECTED]> wrote:
I want to change visibility attribute of a panel (containing other components) using Ajax.

The panel initially is hidden  panel.setVisible( false ).

When user change selection in a radio group the panel should become visible.

I've tried to do something like that :

radio.add( new AjaxFormComponentUpdatingBehavior("onclick") {
  
    protected void onUpdate(AjaxRequestTarget target) {
        panel.setVisible( true );
        target.addComponent(panel);
    }
  
} );

But it don't work. Using the AJAX Debugger I could see that event is raised but it reports the following error:

ERROR: Component with id [[form1_panel]] a was not found while trying to perform markup update. Make sure you called component.setOutputMarkupId(true) on the component whose markup you are trying to update.
ERROR: error while processing response: [object Error].Object required

Obviuosly I used setOutputMarkupId(true) on panel.

Any idea why it don't work?


Thanks for helping.

- Paolo

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to