How to send a Java object to the ModalWindow

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to send a Java object to the ModalWindow

zoran
Hi,

I used the approach described in http://stuq.nl/weblog/2008-06-05/wicket-how-to-write-a-reusable-modal-window-popup to create a ModalWindow panel with the input form. Everything works fine, but I need to send a Java object instance to the panel before calling selectModalWindow.show(target), so the panel can use the information to set some form values and change the object after the form submit.

Can you suggest me how to make this?

Zoran
Reply | Threaded
Open this post in threaded view
|

Re: How to send a Java object to the ModalWindow

Martin Makundi
There are many ways. This is one way:

modalWindow.setContent(new MyPanel(modalWindow.getContentId()) {
   @Override
   public MagicObject getMagicObject() {
       return magicObject;
   }
});


Also you can just pass your java object as parameter to myPanel or if
it is dynamic you can wrap it into a Model.

**
Martin

2010/8/4 zoran <[hidden email]>:

>
> Hi,
>
> I used the approach described in
> http://stuq.nl/weblog/2008-06-05/wicket-how-to-write-a-reusable-modal-window-popup
> to create a ModalWindow panel with the input form. Everything works fine,
> but I need to send a Java object instance to the panel before calling
> selectModalWindow.show(target), so the panel can use the information to set
> some form values and change the object after the form submit.
>
> Can you suggest me how to make this?
>
> Zoran
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-send-a-Java-object-to-the-ModalWindow-tp2312589p2312589.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to send a Java object to the ModalWindow

zoran
Hi Martin,

I'm using dynamic objects. In the first way based on the some event (e.g. tree node selection) I want to setup this MagicObject in home page, and then to show panel. Between these two there should be a call of getMagicObject() from the panel.
How can I set this happen in appropriate moment?

In the third example, I'm not sure how I can send a Model to the Panel. Can you give me some small example?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How to send a Java object to the ModalWindow

Martin Makundi
Hi!

> I'm using dynamic objects. In the first way based on the some event (e.g.
> tree node selection) I want to setup this MagicObject in home page, and then
> to show panel. Between these two there should be a call of getMagicObject()
> from the panel.
> How can I set this happen in appropriate moment?

I don't understand what you mean with appropriate moment if you do it
sequentially assuming there is only one thread operating.

> In the third example, I'm not sure how I can send a Model to the Panel. Can
> you give me some small example?

I can give you an example, but currently I don't exactly understand
your use-case. What is your use case?

Is the modal panel on home page? In that case home page is the one
that opens the modal panel so you can pass (set/constructor
argument/override getter) anything when you open the modal panel and
when you close the modal panel you can get the result if you need it.
If  it is a longer term data you can store it into the session.

A modal panel can be treated same way as any other wicket component,
label for example. How to pass model to label? Simply
new Label("wicket-id", dynamicModel);

For modal window it is the same. You create the modal window panel
when you open it. If you want to create the panel before opening it
then you must pass it a dynamicModel whose value is correct when it is
opened (it is set somewhere) or you must appropriately set it in the
open-event. What is the open event? Yes, it is when you call
modalWindow.show(); so you can then call
modalwindowcontent.setpropervalue(xx);

I hope this helps ;) If you give an exact use case I can answer more precisely.

**
Martin

>
> Thanks
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-send-a-Java-object-to-the-ModalWindow-tp2312589p2312657.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to send a Java object to the ModalWindow

zoran
Thanks Martin,

>modalwindowcontent.setpropervalue(xx);
That's what I have tried first, but for some reason it didn't worked than so I started to work on some other more complex solution.
Now I turned again to this simple idea and it works.

Zoran
Reply | Threaded
Open this post in threaded view
|

Re: How to send a Java object to the ModalWindow

Iamuser
Hello,

I know this is a long overdue thread, but could you please explain how you did it?