You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Crash_neo <cr...@mytweakers.net> on 2007/08/01 00:54:30 UTC

Re: home page with parameters

I'm not sure if this is possible. It sounds a bit strange to me.

But if you want the homepage to use the same bean class and dao every time
the website is visited the first time, why not make that the default
constructor? And if you want to be able to use the same page with a
diferrent bean/dao set, add an extra constructor

example with pageparameters:

public Index()
{
   
   init("daoName", "BeanName");
}

public Index(PageParameters params)
{
   String daoName = params.getString("dao");
   String beanName = params.getString("bean");
   {...do some checks...}
   init(daoName, beanName);
}

private init(String daoName, String beanName)
{
   do some reflection thingie...
}

Or if you don't want to use PageParameters:

public Index()
{   
   this(new XDao(), new ABean());
}

public Index(Doa dao, Bean bean)
{
...
}


Hope this helps...


Edgar Poce wrote:
> 
> Hi,
> 
> In my application I'd like to add a home page that displays a
> collection of beans from a dao, I'd like to pass the bean class and
> the DAO instance as constructor's parameters. it possible to define a
> page with parameters in the constructor as the home page?.
> 
> thanks in advance,
> edgar
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/home-page-with-parameters-tf4196659.html#a11936706
Sent from the Wicket - User 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: home page with parameters

Posted by Frank Bille <fr...@apache.org>.
I normally do something like this:

application.getHomePage() {return HomePage.class}

HomePage.java
public HomePage() {
   // Check the current state of everything
   if (state == WORLD) {
      throw new RestartResponseException(ThePage.class, new
PageParameters());
   }
}

Frank


On Jan 22, 2008 9:03 AM, Newgro <pe...@gmx.ch> wrote:

>
> Did you get a solution for this?
> I have the same problem and i would be glad to solve this.
>
> Cheers
> Per
> --
> View this message in context:
> http://www.nabble.com/home-page-with-parameters-tp11935608p15014223.html
> Sent from the Wicket - User 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: home page with parameters

Posted by Newgro <pe...@gmx.ch>.
Did you get a solution for this?
I have the same problem and i would be glad to solve this.

Cheers
Per
-- 
View this message in context: http://www.nabble.com/home-page-with-parameters-tp11935608p15014223.html
Sent from the Wicket - User 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: home page with parameters

Posted by Edgar Poce <ed...@gmail.com>.
Hi,

On 7/31/07, Crash_neo <cr...@mytweakers.net> wrote:
>
> I'm not sure if this is possible. It sounds a bit strange to me.
>
> But if you want the homepage to use the same bean class and dao every time
> the website is visited the first time, why not make that the default
> constructor?

I'm giving a try to the portlet support available in a subversion
branch. The general idea is that the wicket application creates the
home page with the bean type and the dao specified in the portlet init
params.

> And if you want to be able to use the same page with a
> diferrent bean/dao set, add an extra constructor
>

The question is how can I  specify the parameters in the Application
for the home page?. AFAIK the only way to define the home page is
"public Class Application.getHomePage()". AFAIK, in the example you
are providing bellow you declare constructors that won't be used by
the framework to create the home page. AFAIK the only constructor that
will be used is "public Index() ...".

> example with pageparameters:
>
> public Index()
> {
>
>    init("daoName", "BeanName");
> }
>
> public Index(PageParameters params)
> {
>    String daoName = params.getString("dao");
>    String beanName = params.getString("bean");
>    {...do some checks...}
>    init(daoName, beanName);
> }
>
> private init(String daoName, String beanName)
> {
>    do some reflection thingie...
> }
>
> Or if you don't want to use PageParameters:
>
> public Index()
> {
>    this(new XDao(), new ABean());
> }
>
> public Index(Doa dao, Bean bean)
> {
> ...
> }
>
>
> Hope this helps...
>

thank you very much for your help

br,
edgar

>
> Edgar Poce wrote:
> >
> > Hi,
> >
> > In my application I'd like to add a home page that displays a
> > collection of beans from a dao, I'd like to pass the bean class and
> > the DAO instance as constructor's parameters. it possible to define a
> > page with parameters in the constructor as the home page?.
> >
> > thanks in advance,
> > edgar
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/home-page-with-parameters-tf4196659.html#a11936706
> Sent from the Wicket - User 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
>
>

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