You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stanczak Group <ju...@stanczakgroup.com> on 2007/10/02 20:38:19 UTC

Passing Values Between Pages?

New person question here. I just started using Wicket, but I don't 
understand how to pass values to other pages. Can't seem to find 
examples. Here's what I setup so far, but it doesn't seem to work. Just 
started using Wicket yesterday. Also, how do I put something in a 
application wide session. Like a login id?

        @Override
        protected void onSubmit() {
            StudentInformationPage page = new StudentInformationPage();
            page.setVisitDate(visitDate);
            setResponsePage(page);
        }

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


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


RE: Making ExternalLink invisible: test for what?

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
It's an anonymous class and I don't create an identifier for it but I
suppose I can still use:

add(new ExternalLink(..,..,..).setVisible(condition));

"Back in my day we didn't need Tapestry, or Wicket or WebObjects, or
even Servlets, or for that matter Java! We just coded in plain assembly
language. And before that we had to just type in 1's and 0's. Sometimes
we didn't even have 1's. I once had to code for an entire month,
barefoot, in the dead of winter, using just 0's... but you didn't hear
me complaining."

> -----Original Message-----
> From: Martijn Dashorst [mailto:martijn.dashorst@gmail.com]
> Sent: Wednesday, 3 October 2007 4:36 PM
> To: users@wicket.apache.org
> Subject: Re: Making ExternalLink invisible: test for what?
> 
> why not use the setVisible method?
> 
> link.setVisible(StringUtils.isNotBlank(url) &&
> StringUtils.isNotBlank(...));
> 
> Martijn
> 
> On 10/3/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
> > I have content that I render that may or may not have a URL
associated
> > with it. I don't want to display anything if the URL is blank.
> >
> > I use ExternalLink for the URLs. As I place a reference to the link
in
> > my markup I need to instantiate an ExternalLink object in the
> > corresponding page/panel classes using an anonymous class with
> > overridden isVisible method:
> >
> > add(
> >         new ExternalLink("externallink",
> >                 "http://" + content.getUrl(),
> >                 contentList.getUrl())
> >         {
> >                 public boolean isVisible()
> >                 {
> >                         WHAT DO I TEST FOR HERE TO CHECK IF A NON
NULL
> > AND
> >                         NON BLANK URL WAS       PROVIDED BY
> > content.getUrl()?                                       return
what?;
> >                 }
> >         }
> > );
> >
> > I don't know what attribute or method to text to access the URL that
is
> > configured by the ExternalLink constructor. If it's stored as a
string I
> > basically want to go return true if (url != null && url.length() >
0)
> > but after handing the URL onto the contructor I don't know how to
get it
> > back to test it.
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> 
> --
> Buy Wicket in Action: http://manning.com/dashorst
> Apache Wicket 1.3.0-beta3 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
> 
> ---------------------------------------------------------------------
> 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


Re: Making ExternalLink invisible: test for what?

Posted by Martijn Dashorst <ma...@gmail.com>.
why not use the setVisible method?

link.setVisible(StringUtils.isNotBlank(url) && StringUtils.isNotBlank(...));

Martijn

On 10/3/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
> I have content that I render that may or may not have a URL associated
> with it. I don't want to display anything if the URL is blank.
>
> I use ExternalLink for the URLs. As I place a reference to the link in
> my markup I need to instantiate an ExternalLink object in the
> corresponding page/panel classes using an anonymous class with
> overridden isVisible method:
>
> add(
>         new ExternalLink("externallink",
>                 "http://" + content.getUrl(),
>                 contentList.getUrl())
>         {
>                 public boolean isVisible()
>                 {
>                         WHAT DO I TEST FOR HERE TO CHECK IF A NON NULL
> AND
>                         NON BLANK URL WAS       PROVIDED BY
> content.getUrl()?                                       return what?;
>                 }
>         }
> );
>
> I don't know what attribute or method to text to access the URL that is
> configured by the ExternalLink constructor. If it's stored as a string I
> basically want to go return true if (url != null && url.length() > 0)
> but after handing the URL onto the contructor I don't know how to get it
> back to test it.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

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


Re: Making ExternalLink invisible: test for what?

Posted by Igor Vaynberg <ig...@gmail.com>.
please look at the code, they are called gethref() and getlabel() and return
exactly what you put into the constructor

-igor


On 10/2/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
>
> > i added the missing getters, update from trunk and you should be good.
>
> Thanks Igor, but what are they called? getUrl(), getDisplay()?
>
> Actually the display text is more valuable because it doesn't have the
> http:// prefix so I can do a simple null or blank text whereas the URL
> will always have a http:// in front of it making a trivial test not
> possible.
>
> >
> > -igor
> >
> >
> > On 10/2/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
> > >
> > > I have content that I render that may or may not have a URL
> associated
> > > with it. I don't want to display anything if the URL is blank.
> > >
> > > I use ExternalLink for the URLs. As I place a reference to the link
> in
> > > my markup I need to instantiate an ExternalLink object in the
> > > corresponding page/panel classes using an anonymous class with
> > > overridden isVisible method:
> > >
> > > add(
> > >         new ExternalLink("externallink",
> > >                 "http://" + content.getUrl(),
> > >                 contentList.getUrl())
> > >         {
> > >                 public boolean isVisible()
> > >                 {
> > >                         WHAT DO I TEST FOR HERE TO CHECK IF A NON
> NULL
> > > AND
> > >                         NON BLANK URL WAS       PROVIDED BY
> > > content.getUrl()?                                       return
> what?;
> > >                 }
> > >         }
> > > );
> > >
> > > I don't know what attribute or method to text to access the URL that
> is
> > > configured by the ExternalLink constructor. If it's stored as a
> string I
> > > basically want to go return true if (url != null && url.length() >
> 0)
> > > but after handing the URL onto the contructor I don't know how to
> get it
> > > back to test it.
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > 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
>
>

RE: Making ExternalLink invisible: test for what?

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
> i added the missing getters, update from trunk and you should be good.

Thanks Igor, but what are they called? getUrl(), getDisplay()?

Actually the display text is more valuable because it doesn't have the
http:// prefix so I can do a simple null or blank text whereas the URL
will always have a http:// in front of it making a trivial test not
possible.

> 
> -igor
> 
> 
> On 10/2/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
> >
> > I have content that I render that may or may not have a URL
associated
> > with it. I don't want to display anything if the URL is blank.
> >
> > I use ExternalLink for the URLs. As I place a reference to the link
in
> > my markup I need to instantiate an ExternalLink object in the
> > corresponding page/panel classes using an anonymous class with
> > overridden isVisible method:
> >
> > add(
> >         new ExternalLink("externallink",
> >                 "http://" + content.getUrl(),
> >                 contentList.getUrl())
> >         {
> >                 public boolean isVisible()
> >                 {
> >                         WHAT DO I TEST FOR HERE TO CHECK IF A NON
NULL
> > AND
> >                         NON BLANK URL WAS       PROVIDED BY
> > content.getUrl()?                                       return
what?;
> >                 }
> >         }
> > );
> >
> > I don't know what attribute or method to text to access the URL that
is
> > configured by the ExternalLink constructor. If it's stored as a
string I
> > basically want to go return true if (url != null && url.length() >
0)
> > but after handing the URL onto the contructor I don't know how to
get it
> > back to test it.
> >
> >
> >
---------------------------------------------------------------------
> > 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


Re: Making ExternalLink invisible: test for what?

Posted by Igor Vaynberg <ig...@gmail.com>.
i added the missing getters, update from trunk and you should be good.

-igor


On 10/2/07, Chris Colman <ch...@stepaheadsoftware.com> wrote:
>
> I have content that I render that may or may not have a URL associated
> with it. I don't want to display anything if the URL is blank.
>
> I use ExternalLink for the URLs. As I place a reference to the link in
> my markup I need to instantiate an ExternalLink object in the
> corresponding page/panel classes using an anonymous class with
> overridden isVisible method:
>
> add(
>         new ExternalLink("externallink",
>                 "http://" + content.getUrl(),
>                 contentList.getUrl())
>         {
>                 public boolean isVisible()
>                 {
>                         WHAT DO I TEST FOR HERE TO CHECK IF A NON NULL
> AND
>                         NON BLANK URL WAS       PROVIDED BY
> content.getUrl()?                                       return what?;
>                 }
>         }
> );
>
> I don't know what attribute or method to text to access the URL that is
> configured by the ExternalLink constructor. If it's stored as a string I
> basically want to go return true if (url != null && url.length() > 0)
> but after handing the URL onto the contructor I don't know how to get it
> back to test it.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Making ExternalLink invisible: test for what?

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
I have content that I render that may or may not have a URL associated
with it. I don't want to display anything if the URL is blank.

I use ExternalLink for the URLs. As I place a reference to the link in
my markup I need to instantiate an ExternalLink object in the
corresponding page/panel classes using an anonymous class with
overridden isVisible method:

add(
	new ExternalLink("externallink",
		"http://" + content.getUrl(),
		contentList.getUrl())
	{
		public boolean isVisible()
		{
			WHAT DO I TEST FOR HERE TO CHECK IF A NON NULL
AND
			NON BLANK URL WAS	PROVIDED BY
content.getUrl()?					return what?;
		}
	}
);
	
I don't know what attribute or method to text to access the URL that is
configured by the ExternalLink constructor. If it's stored as a string I
basically want to go return true if (url != null && url.length() > 0)
but after handing the URL onto the contructor I don't know how to get it
back to test it.


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


Re: Passing Values Between Pages?

Posted by Stanczak Group <ju...@stanczakgroup.com>.
Ok, thanks.

Igor Vaynberg wrote:
> On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>   
>> Why would I need to override the WebSession? Can't I just use it as is?
>>     
>
>
>
> the idea is that you add your typesafe properties and getters/setters into
> your subclass. we do not provide a generic map for attributes like the
> httpsession does.
>
> -igor
>
>
>
>   
>>>
>>> --
>>>
>>>       
>>>> Justin Stanczak
>>>> Stanczak Group
>>>> 812-735-3600
>>>>
>>>> "All that is necessary for the triumph of evil is that good men do
>>>> nothing."
>>>> Edmund Burke
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>         
>>>       
>> --
>> Justin Stanczak
>> Stanczak Group
>> 812-735-3600
>>
>> "All that is necessary for the triumph of evil is that good men do
>> nothing."
>> Edmund Burke
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


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


Re: Passing Values Between Pages?

Posted by Igor Vaynberg <ig...@gmail.com>.
On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>
> >
> Why would I need to override the WebSession? Can't I just use it as is?



the idea is that you add your typesafe properties and getters/setters into
your subclass. we do not provide a generic map for attributes like the
httpsession does.

-igor



>
> >
> >
> >
> > --
> >
> >> Justin Stanczak
> >> Stanczak Group
> >> 812-735-3600
> >>
> >> "All that is necessary for the triumph of evil is that good men do
> >> nothing."
> >> Edmund Burke
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >>
> >
> >
>
> --
> Justin Stanczak
> Stanczak Group
> 812-735-3600
>
> "All that is necessary for the triumph of evil is that good men do
> nothing."
> Edmund Burke
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Passing Values Between Pages?

Posted by Stanczak Group <ju...@stanczakgroup.com>.

Igor Vaynberg wrote:
> On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>   
>> New person question here. I just started using Wicket, but I don't
>> understand how to pass values to other pages. Can't seem to find
>> examples. Here's what I setup so far, but it doesn't seem to work. Just
>> started using Wicket yesterday.
>>     
>
>
>
>   
>>         @Override
>>         protected void onSubmit() {
>>             StudentInformationPage page = new StudentInformationPage();
>>             page.setVisitDate(visitDate);
>>             setResponsePage(page);
>>         }
>>     
>
>
> what you do there is fine. what exactly doesnt work? also i find it helpful
> to do this in the page constructor instead of a setter because it makes
> things a bit more explicit.
>   
Ya, I just found a good tutorial page. Here's what I'm doing now.

        @Override
        protected void onSubmit() {
            setResponsePage(new StudentInformationPage((Student) 
getModelObject()));
        }
>
>   
>> Also, how do I put something in a application wide session. Like a login
>>     
> id?
>
> create your own subclass of WebSession object and add a private long
> loginid; into it with a setter and getter. then in your subclass of
> webapplication override newsession(..) and return an instance of your
> subclass. then it is available anywhere, just cast it:
>
> ((MySession)getSession()).setloginid(..); or
> ((MySession)Session.get()).setloginid(..);
>
> -igor
>   
Why would I need to override the WebSession? Can't I just use it as is?
>
>
>
>
> --
>   
>> Justin Stanczak
>> Stanczak Group
>> 812-735-3600
>>
>> "All that is necessary for the triumph of evil is that good men do
>> nothing."
>> Edmund Burke
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   

-- 
Justin Stanczak
Stanczak Group
812-735-3600

"All that is necessary for the triumph of evil is that good men do nothing."
Edmund Burke


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


Re: Passing Values Between Pages?

Posted by Igor Vaynberg <ig...@gmail.com>.
On 10/2/07, Stanczak Group <ju...@stanczakgroup.com> wrote:
>
> New person question here. I just started using Wicket, but I don't
> understand how to pass values to other pages. Can't seem to find
> examples. Here's what I setup so far, but it doesn't seem to work. Just
> started using Wicket yesterday.



>         @Override
>         protected void onSubmit() {
>             StudentInformationPage page = new StudentInformationPage();
>             page.setVisitDate(visitDate);
>             setResponsePage(page);
>         }


what you do there is fine. what exactly doesnt work? also i find it helpful
to do this in the page constructor instead of a setter because it makes
things a bit more explicit.


> Also, how do I put something in a application wide session. Like a login
id?

create your own subclass of WebSession object and add a private long
loginid; into it with a setter and getter. then in your subclass of
webapplication override newsession(..) and return an instance of your
subclass. then it is available anywhere, just cast it:

((MySession)getSession()).setloginid(..); or
((MySession)Session.get()).setloginid(..);

-igor





--
> Justin Stanczak
> Stanczak Group
> 812-735-3600
>
> "All that is necessary for the triumph of evil is that good men do
> nothing."
> Edmund Burke
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>