As Igor mentioned. It is completely fine to use. Nothing wrong with it. Juergen
On 11/20/05, Andrew Lombardi <[EMAIL PROTECTED]> wrote: > So, I see all this talk of using static factory methods to generate a > Page, but what would be wrong with just using > > add(new Link("myLink") { > public void onClick() { > setResponsePage(new MyPage(param1, param2, param3)); > } > }; > > this looks like it ensures that the page doesn't get created until > the link is clicked (avoiding the stack overflow problem), and it > avoids usage of PageParameters (which harken me back to MVC > frameworks anyway (ick!))... > > is that right? > > > On Nov 18, 2005, at 3:19 PM, Eduardo Rocha wrote: > > > Yeah, I just forgot IPageLink and PageLink (by the way these names can > > be quite confusing!), so ignore my classes, but I keep my point :P. > > > > 2005/11/18, Igor Vaynberg <[EMAIL PROTECTED]>: > >> Actually what i meant was a simple static factory method that > >> translates > >> strongly typed params into PageParameters. > >> > >> ie > >> > >> class MyBookmarkablePage extends WebPage { > >> public MyBookmarkablePage(PageParameters params) { > >> ... > >> } > >> public static MyBookmarkablePage(String p1, int p2, String p3) { > >> PageParameters params=new PageParameters(); > >> ...fill in params... > >> return new MyBookmarkablePage(params); > >> } > >> } > >> > >> also see IPageLink interface that is used by PageLink class. but i > >> think > >> this is more work, a simple Link's onclick() implementation is the > >> path of > >> least resistance imho. > >> > >> -Igor > >> > >> > >> > >> On 11/18/05, Eduardo Rocha <[EMAIL PROTECTED]> wrote: > >>> > >>> If it's OK to write a little more code, you could use a factory for > >>> the page with the same signature your constructor uses. In my > >>> opinion > >>> this could be more elegant, but what Igor said is simpler. Something > >>> like (not tested): > >>> > >>> // reusable class > >>> public interface IPageCreator { > >>> Page newInstance(); > >>> } > >>> > >>> // reusable class > >>> public class PageCreatorLink extends Link { > >>> public PageCreatorLink(String id, IPageCreator creator) { > >>> super(id); > >>> this.creator = creator; > >>> } > >>> public void onClick() { > >>> setResponsePage(creator.newInstance()); > >>> } > >>> } > >>> > >>> // your class > >>> public class MyPageCreator implements IPageCreator { > >>> public MyPageCreator(Object provided) { > >>> this.provided = provided; > >>> } > >>> public Page newInstance() { > >>> return new MyPage(provided); > >>> } > >>> } > >>> > >>> // your class > >>> add(new PageCreatorLink("cancelLink", new MyPageCreator(provided)); > >>> > >>> maybe your page class could also be the IPageCreator, serving like a > >> prototype: > >>> > >>> // your class > >>> public class MyPage extends WebPage implements IPageCreator { > >>> .... > >>> } > >>> > >>> The factory would be nice when you have to execute some service > >>> method > >>> before rendering the page, so you would have more clearly separated > >>> responsabilities, i.e., the factory would be responsible for calling > >>> the service and the page would act just for the view. That way your > >>> classes would be more testable too. > >>> > >>> 2005/11/18, Igor Vaynberg <[EMAIL PROTECTED]>: > >>>> imho that is the best practice. that is what i use whenever i do > >>>> not > >> need a > >>>> bookmarkable page. i have yet to use the PageLink class. > >>>> PageLink makes > >> it > >>>> easier to create links to pages because it lets you specify the > >>>> class > >> name > >>>> of the page or the created page instance. This is ok for pages > >>>> that are > >> not > >>>> bookmarkable and take no parameters, but most of the time that > >>>> is not > >> the > >>>> case in my experience. > >>>> > >>>> if you work with bookmarkable pages a lot, a static factory > >>>> method that > >>>> fills in pageparameters can help with type safety and forgotten > >>>> params. > >>>> > >>>> -Igor > >>>> > >>>> > >>>> > >>>> On 11/18/05, Gustavo Hexsel <[EMAIL PROTECTED]> wrote: > >>>>> Hi all, > >>>>> > >>>>> I wanted to know what's the best way to use Links (PageLinks, > >>>> BookmarkablePageLinks). > >>>>> > >>>>> In the beginning, I was using BookmarkablePageLink's and > >>>>> converting > >>>> everything to and from Strings. That obviously was flawed, as I > >>>> was > >> using > >>>> string names and passing them back and forth (lost strong-typing, > >>>> occasionally forgot one parameter, or mistyped the name of it). > >>>> It also > >>>> made me reload objects from the database even though I had them > >>>> handy on > >> the > >>>> calling class. > >>>>> > >>>>> Then I tried using PageLink's, passing a "new > >>>> XXXPage(whateverparameter)" in the constructor. That didn't work > >> either, as > >>>> pages have links back and forth, leading to stackoverflows. > >>>>> > >>>>> Then I moved one step up in the object hierarchy and started > >>>>> using > >>>> Link's, but it seems such red tape for each link having to write: > >>>>> add(new Link("cancelLink") { > >>>>> public void onClick() { setResponsePage(new > >>>> EditProviderPage(provider)); }; > >>>>> }); > >>>>> > >>>>> Any suggestions? > >>>>> > >>>>> > >>>>> []s Gus > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >> ------------------------------------------------------- > >>>>> This SF.Net email is sponsored by the JBoss Inc. Get Certified > >>>>> Today > >>>>> Register for a JBoss Training Course. Free Certification Exam > >>>>> for All Training Attendees Through End of 2005. For more info > >>>>> visit: > >>>>> http://ads.osdn.com/?ad_idv28&alloc_id845&opclick > >>>>> _______________________________________________ > >>>>> Wicket-user mailing list > >>>>> Wicket-user@lists.sourceforge.net > >>>>> > >> https://lists.sourceforge.net/lists/listinfo/wicket-user > >>>>> > >>>> > >>>> > >>> > >>> > >>> ------------------------------------------------------- > >>> This SF.Net email is sponsored by the JBoss Inc. Get Certified > >>> Today > >>> Register for a JBoss Training Course. Free Certification Exam > >>> for All Training Attendees Through End of 2005. For more info visit: > >>> http://ads.osdn.com/?ad_idv28&alloc_id845&opclick > >>> _______________________________________________ > >>> Wicket-user mailing list > >>> Wicket-user@lists.sourceforge.net > >>> https://lists.sourceforge.net/lists/listinfo/wicket-user > >>> > >> > >> > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > > Register for a JBoss Training Course. Free Certification Exam > > for All Training Attendees Through End of 2005. For more info visit: > > http://ads.osdn.com/?ad_idv28&alloc_id845&opÌk > > _______________________________________________ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. Get Certified Today > Register for a JBoss Training Course. Free Certification Exam > for All Training Attendees Through End of 2005. For more info visit: > http://ads.osdn.com/?ad_idv28&alloc_id845&opclick > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit: http://ads.osdn.com/?ad_idv28&alloc_id845&op=click _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user