You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by theivorykitty <ch...@frontier.com> on 2012/09/13 07:57:53 UTC

Adding the same panel with different parameters...

Hey guys! First time post -

So, I have a page that has two buttons (among other things) - one is to
create a new object, and one is to edit an already existing object.

I have a customization panel that allows the user to change the object's
name, and other data.

When the user enters the page, I'd like the customization page to be
non-visible. When the user selects the link to create a new object, I want
to bring up the panel, passing in the parameter of a new object. If the user
selects the link to edit an existing object, however, I want to bring up the
same panel, but pass in the parameter of the existing object.

The problem is, with Wicket I have to give it SOMETHING when the page first
comes up, so I do the following:

        cPanel = new CPanel("cPanel", newObject);
        add(cPanel);
        cPanel.setOutputMarkupPlaceholderTag(true);
        cPanel.setVisible(false);

And when they select the "Create New Object" button, its easy to just do the
following in the link:

                cPanel.setVisible(true);
                target.add(cPanel, cPanel.getMarkupId());

However, what the heck am I supposed to do when they click the button to
edit an existing object? The panel has already been created, and when I do a
replaceWith(), it doesn't like it (I think because the customization panel
isn't visible yet when the user clicks the edit button)...

Oh, and I should mention that I don't know which object they're going to
edit until they click the edit button, so I don't have the object on page
generation to just make an entirely different panel with that parameter, add
both, set them both to invisible, and then change visibility as the need
arises. I've pulled that one before!

So basically, how do I switch an invisible panel with a different one (of
the same type with a different parameter) before I bring up visibility?

Sorry if this is a silly question! Any help would be great!

Thanks!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-the-same-panel-with-different-parameters-tp4651967.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Adding the same panel with different parameters...

Posted by theivorykitty <ch...@frontier.com>.
Oooo spiffy! I'm going to try that! :D Thanks 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-the-same-panel-with-different-parameters-tp4651967p4651972.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Adding the same panel with different parameters...

Posted by heapifyman <he...@gmail.com>.
Make CPanel extend GenericPanel.
Then use cPanel.setModelObject() and pass it newObject or editObject
depending on which button has been clicked.



2012/9/13 theivorykitty <ch...@frontier.com>

> Hey guys! First time post -
>
> So, I have a page that has two buttons (among other things) - one is to
> create a new object, and one is to edit an already existing object.
>
> I have a customization panel that allows the user to change the object's
> name, and other data.
>
> When the user enters the page, I'd like the customization page to be
> non-visible. When the user selects the link to create a new object, I want
> to bring up the panel, passing in the parameter of a new object. If the
> user
> selects the link to edit an existing object, however, I want to bring up
> the
> same panel, but pass in the parameter of the existing object.
>
> The problem is, with Wicket I have to give it SOMETHING when the page first
> comes up, so I do the following:
>
>         cPanel = new CPanel("cPanel", newObject);
>         add(cPanel);
>         cPanel.setOutputMarkupPlaceholderTag(true);
>         cPanel.setVisible(false);
>
> And when they select the "Create New Object" button, its easy to just do
> the
> following in the link:
>
>                 cPanel.setVisible(true);
>                 target.add(cPanel, cPanel.getMarkupId());
>
> However, what the heck am I supposed to do when they click the button to
> edit an existing object? The panel has already been created, and when I do
> a
> replaceWith(), it doesn't like it (I think because the customization panel
> isn't visible yet when the user clicks the edit button)...
>
> Oh, and I should mention that I don't know which object they're going to
> edit until they click the edit button, so I don't have the object on page
> generation to just make an entirely different panel with that parameter,
> add
> both, set them both to invisible, and then change visibility as the need
> arises. I've pulled that one before!
>
> So basically, how do I switch an invisible panel with a different one (of
> the same type with a different parameter) before I bring up visibility?
>
> Sorry if this is a silly question! Any help would be great!
>
> Thanks!
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Adding-the-same-panel-with-different-parameters-tp4651967.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>