You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2016/05/10 06:54:05 UTC

Which model to use for forwarding form processing results?

Hi all,

I have one and the same form on different pages used to provide some
input data which is afterwards used by the form's onSubmit handler to
request some complex data structure from a 3rd party service. This
result needs to be forwarded to the caller/owner of the form, mainly
pages, so those can provide the data to different views focussing on
different aspects of the data. Most of those views are panels using
different DataViews to provide data in HTML tables in the end.

The important thing is that the form shouldn't render the results
itself, only return some raw data structure, and the panels shouldn't
need to know about the form as well.

What is the best way to send those resulting data around?

From my understanding it's not the default model of the form with all
the convert input stuff, those input comes from the user, but it may
be that of the page containing form and panels, so both could access
the page and its default model. Else I could simply create a model
instance and forward it using the CTORs of the form and panels,
without (misusing?) the page's default model.

Does it even matter at all?

Thanks!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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


Re: Which model to use for forwarding form processing results?

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Bas Gooren,
am Dienstag, 10. Mai 2016 um 20:48 schrieben Sie:

> Yes, that is normal behavior I think - for invisible components we
> either wrap it in a container which receives the event, or let the page be the coordinator.

I found overriding Component.canCallListenerInterface easier to
maintain and suggested an improvement to the dispatcher:

https://github.com/wicketstuff/core/issues/493

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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


Re: Which model to use for forwarding form processing results?

Posted by Bas Gooren <ba...@iswd.nl>.
Thorsten,

Yes, that is normal behavior I think - for invisible components we either wrap it in a container which receives the event, or let the page be the coordinator.

Invisible components also don’t receive clicks on links etc, so I think this was done to be consistent.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 10 mei 2016 bij 19:48:48, Thorsten Schöning (tschoening@am-soft.de) schreef:

Guten Tag Bas Gooren,  
am Dienstag, 10. Mai 2016 um 13:43 schrieben Sie:  

> This sounds like a good use-case for an event.  

Thanks for this hint, I totally forgot about it and decided to give it  
a try. There was a pitfall in my case, though: Component.canCallListenerInterface  
is asked before an event is dispatched and I'm starting with an  
invisible panel, so the method returns false, waiting for data to  
become visible, which is never dispatched... Doesn't seem to be  
mentioned in the docs or I must have missed it.  

Mit freundlichen Grüßen,  

Thorsten Schöning  

--  
Thorsten Schöning E-Mail: Thorsten.Schoening@AM-SoFT.de  
AM-SoFT IT-Systeme http://www.AM-SoFT.de/  

Telefon...........05151- 9468- 55  
Fax...............05151- 9468- 88  
Mobil..............0178-8 9468- 04  

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln  
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow  


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


Re: Which model to use for forwarding form processing results?

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Bas Gooren,
am Dienstag, 10. Mai 2016 um 13:43 schrieben Sie:

> This sounds like a good use-case for an event.

Thanks for this hint, I totally forgot about it and decided to give it
a try. There was a pitfall in my case, though: Component.canCallListenerInterface
is asked before an event is dispatched and I'm starting with an
invisible panel, so the method returns false, waiting for data to
become visible, which is never dispatched... Doesn't seem to be
mentioned in the docs or I must have missed it.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


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


Re: Which model to use for forwarding form processing results?

Posted by Bas Gooren <ba...@iswd.nl>.
Hi Thorsten,

This sounds like a good use-case for an event.

You can have the form broadcast an event to the page, and let any component that needs to redraw based on the data handle that event. This provides a nice decoupling between the form result and 0…n other components in your page that need the data.

The components handling the event then also don’t need to know where the event originated.

For more info, see the wicket guide; the info is under chapter 17.2, scroll down to “Wicket events infrastructure”.
https://ci.apache.org/projects/wicket/guide/6.x/guide/advanced.html#advanced_2

And a bonus tip: you can use the wicketstuff-annotationeventdispatcher jar to make your life even easier. Just include it in your project (it will automatically register itself in wicket), and then you can annotate any public component method in your page with @OnEvent, for example:

@OnEvent
public void onFormDataSubmittedEvent(FormDateSubmittedEvent event) {
… impl
}

It’s actually a great way to handle data-passing in pages.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 10 mei 2016 bij 08:54:14, Thorsten Schöning (tschoening@am-soft.de) schreef:

Hi all,  

I have one and the same form on different pages used to provide some  
input data which is afterwards used by the form's onSubmit handler to  
request some complex data structure from a 3rd party service. This  
result needs to be forwarded to the caller/owner of the form, mainly  
pages, so those can provide the data to different views focussing on  
different aspects of the data. Most of those views are panels using  
different DataViews to provide data in HTML tables in the end.  

The important thing is that the form shouldn't render the results  
itself, only return some raw data structure, and the panels shouldn't  
need to know about the form as well.  

What is the best way to send those resulting data around?  

From my understanding it's not the default model of the form with all  
the convert input stuff, those input comes from the user, but it may  
be that of the page containing form and panels, so both could access  
the page and its default model. Else I could simply create a model  
instance and forward it using the CTORs of the form and panels,  
without (misusing?) the page's default model.  

Does it even matter at all?  

Thanks!  

Mit freundlichen Grüßen,  

Thorsten Schöning  

--  
Thorsten Schöning E-Mail: Thorsten.Schoening@AM-SoFT.de  
AM-SoFT IT-Systeme http://www.AM-SoFT.de/  

Telefon...........05151- 9468- 55  
Fax...............05151- 9468- 88  
Mobil..............0178-8 9468- 04  

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln  
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow  


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