Yes - typically it is a good idea to do things like service-layer / database access inside the model or inside onBeforeRender / isVisible, etc, rather than doing your business logic and calling setVisible(), etc.
One of the main reasons for this is that if you don't, your page won't work properly when you click a link that modifies something on the page - because it doesn't reconstruct the page, and therefore you don't refresh the data in your components. On Wed, Jan 14, 2009 at 11:09 AM, behrica <[email protected]>wrote: > > Hello, > > I do something similar in a page constructor, even with accessing the > service layer. I have the same concerns, if this is correct. In general I > do > not like if a constructor does any significant (eventually time consuming) > work like database access or other. But I did not find an other solution > neither. > Maybe it could be "postponed" by using a model which executes the needed > calls to the service layer in an lazy fashion. > > Carsten > > > Jonas505 wrote: > > > > Thank you for the quick reply. > > > > It's already working fine, I was just wondering if it is best practice to > > call business logik from the constructor: > > > > public PageB(PageParameters p) { > > // can throw an exception: > > DataSet result = callMyBusinessLogik(p.getString("param1"), > > p.getString("param2")); > > preparePageBComponents(result); > > } > > > > Jonas > > > > From: Martijn Dashorst > > 14 Jan 2009 14:24:21 +0100 > > Subject: Re: Where to process PageParameters > > > >> setResponsePage(PageB.class, parameters); > >> > >> or use a bookmarkablepagelink > >> > >> Martijn > >> > >> On Wed, Jan 14, 2009 at 1:06 PM, Jonas505 <[email protected]> > >> wrote: > >> > > >> > Hello, > >> > > >> > I would like to know, where in my WebPage class PageParameters should > >> be > >> > processed. > >> > > >> > I have a page A where you can fill in certain parameters (or select a > >> > predefined set of parameters). Then you submit those parameters which > >> are > >> > given to the business logic to prepare some data. The resulting data > is > >> > shown on page B. I would like that the user can bookmark page B with > >> those > >> > parameters encoded in the URL. > >> > > >> > This works fine with page B having a constructor taking > PageParameters. > >> > However, right now I call the Business-Logik from the constructor of > >> page > >> B, > >> > which seems strange. Am I missing something or is this the way to go? > >> > > >> > Thank you! > >> > Jonas > >> > -- > >> > View this message in context: > >> > http://www.nabble.com/Where-to-process-PageParameters-tp21454742p21454742.html > >> > Sent from the Wicket - User mailing list archive at Nabble.com. > >> > > >> > > >> > --------------------------------------------------------------------- > >> > To unsubscribe, e-mail: [email protected] > >> > For additional commands, e-mail: [email protected] > >> > > >> > > >> > >> > >> > >> -- > >> Become a Wicket expert, learn from the best: http://wicketinaction.com > >> Apache Wicket 1.3.5 is released > >> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > > -- > View this message in context: > http://www.nabble.com/Where-to-process-PageParameters-tp21454742p21460425.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Jeremy Thomerson http://www.wickettraining.com
