You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Struts Two <st...@yahoo.ca> on 2009/02/06 23:35:56 UTC

How to use "s:include" param in s:if

I have run out of options and I was hoping if someone can help me. I have an include tag as follows:

<s:include value="./includes/tabs.jsp">
	<s:param name="tabId" value="%{'tab1'}" />
</s:include>

In my tabs.jsp, I tried to do the following:

<td <s:if test="%{#request.param.tabId == 'tab1'}">class="on" </s:if><s:else>class="off"</s:else> >

But of no avail. Using ${param.tabId}, I can see the value of tablId. I even tried [crazy ideas like]:

<td <s:if test="%{${param.tabId} == 'tab1'}">class="on" </s:if><s:else>class="off"</s:else> >

<td <s:if test="{${param.tabId} == 'tab1'}">class="on" </s:if><s:else>class="off"</s:else> >

Refering to "Struts 2 in action" and "Struts 2 Design and programming" was of no help. 

I would appreciate if anybody helps me on that.

regards,




      __________________________________________________________________
Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at http://ca.beta.messenger.yahoo.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: How to initialize a List property through action configuration

Posted by Martin Gainty <mg...@hotmail.com>.
any objections to allocating on the stack
?
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 




> Date: Sat, 7 Feb 2009 19:49:46 -0500
> From: newton.dave@yahoo.com
> To: user@struts.apache.org
> Subject: Re: How to initialize a List property through action configuration
> 
> Please send brand new messages when starting new threads, otherwise the 
> new threads are deeply embedded in existing, different threads.
> 
> http://i43.tinypic.com/3326m44.png
> 
> Dave
> 
> Struts Two wrote:
> > If I have a property such as
> > 
> > private List<String> myList;
> > ....
> > ....
> > 
> > Is there a way that I can initialize the list through action configuration? I have tried the following:
> > 
> > #action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
> >     #param name="myList"#  {Alarmed,Open} #/param#
> >     #result name="success"#  myQueueContent  #/result#
> >  #/action#
> > 
> > and
> > 
> > #action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
> >     #param name="myList"#  Alarmed #/param#
> >     #param name="myList"#  Open     #/param#
> >     #result name="success"#myQueueContent#/result#
> >  #/action#
> > 
> > For the last case, the list is initialized with Open [which makes sense as Alarmed gets overwritten, but I just wanted to try].
> > 
> > 
> >       __________________________________________________________________
> > Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Windows Liveā„¢: Keep your life in sync. 
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_allup_howitworks_022009

Re: How to initialize a List property through action configuration

Posted by Dave Newton <ne...@yahoo.com>.
Please send brand new messages when starting new threads, otherwise the 
new threads are deeply embedded in existing, different threads.

http://i43.tinypic.com/3326m44.png

Dave

Struts Two wrote:
> If I have a property such as
> 
> private List<String> myList;
> ....
> ....
> 
> Is there a way that I can initialize the list through action configuration? I have tried the following:
> 
> #action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
>     #param name="myList"#  {Alarmed,Open} #/param#
>     #result name="success"#  myQueueContent  #/result#
>  #/action#
> 
> and
> 
> #action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
>     #param name="myList"#  Alarmed #/param#
>     #param name="myList"#  Open     #/param#
>     #result name="success"#myQueueContent#/result#
>  #/action#
> 
> For the last case, the list is initialized with Open [which makes sense as Alarmed gets overwritten, but I just wanted to try].
> 
> 
>       __________________________________________________________________
> Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


How to initialize a List property through action configuration

Posted by Struts Two <st...@yahoo.ca>.
If I have a property such as

private List<String> myList;
....
....

Is there a way that I can initialize the list through action configuration? I have tried the following:

#action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
    #param name="myList"#  {Alarmed,Open} #/param#
    #result name="success"#  myQueueContent  #/result#
 #/action#

and

#action name="queueContent" class="ccol.action.queue.QueueRead"   method="getMyQueueContent"#		
    #param name="myList"#  Alarmed #/param#
    #param name="myList"#  Open     #/param#
    #result name="success"#myQueueContent#/result#
 #/action#

For the last case, the list is initialized with Open [which makes sense as Alarmed gets overwritten, but I just wanted to try].


      __________________________________________________________________
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to use "s:include" param in s:if

Posted by Struts Two <st...@yahoo.ca>.
I was trying to avoid <% if(....) ...%> in my jsps by using request Object and since I am not using JSTL in favor of struts 2 tags, <c:if ...>
tag is not possible.

I have managed to get around the problem with a less favorable approach. My <s:include> now looks like:

<s:include value="./includes/tabs.jsp">
	<s:param name="tab1Class" value="%{'on'}" />
	<s:param name="tab2Class" value="%{'off'}" />
</s:include>

and in my tabs.jsp I have someting:

<td class="${param.tab1Class}" >...</td>
<td class="${param.tab2Class}" >...</td>

What I do not like about this approach is If I add a new tab, I not only have to update tabs.jsp but every single jsp that includes it.

I believe <s:include> tag should be able to handle a simple case like the one I was trying to do.

Anyways, thank you for your replies and time.






--- On Fri, 2/6/09, Wes Wannemacher <we...@wantii.com> wrote:

> From: Wes Wannemacher <we...@wantii.com>
> Subject: Re: How to use "s:include" param in s:if
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Received: Friday, February 6, 2009, 11:48 PM
> On Friday 06 February 2009 18:27:18 Struts Two wrote:
> > Wes ,
> >
> > Thank you for your reply, Unfortunately that does not
> work. The if
> > statement return false [I print ${param.tab1} on the
> page and it has the
> > value 'tab1' yet if statement is false]. I am
> using struts 2.0.14.
> >
> 
> Hmm... Strange. I don't know if it matters, but
> ${param.tab1} probably works 
> because it's a legit EL expression. Your include points
> directly to a JSP, 
> rather than an action. Try doing the whole thing in EL, you
> might be able to 
> accomplish what you're looking for with less hassle. 
> 
> -Wes
> 
> 
> -- 
> 
> Wes Wannemacher
> Author - Struts 2 In Practice 
> Includes coverage of Struts 2.1, Spring, JPA, JQuery,
> Sitemesh and more
> http://www.manning.com/wannemacher
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


      __________________________________________________________________
Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at http://ca.beta.messenger.yahoo.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to use "s:include" param in s:if

Posted by Wes Wannemacher <we...@wantii.com>.
On Friday 06 February 2009 18:27:18 Struts Two wrote:
> Wes ,
>
> Thank you for your reply, Unfortunately that does not work. The if
> statement return false [I print ${param.tab1} on the page and it has the
> value 'tab1' yet if statement is false]. I am using struts 2.0.14.
>

Hmm... Strange. I don't know if it matters, but ${param.tab1} probably works 
because it's a legit EL expression. Your include points directly to a JSP, 
rather than an action. Try doing the whole thing in EL, you might be able to 
accomplish what you're looking for with less hassle. 

-Wes


-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to use "s:include" param in s:if

Posted by Struts Two <st...@yahoo.ca>.
Wes ,

Thank you for your reply, Unfortunately that does not work. The if statement return false [I print ${param.tab1} on the page and it has the value 'tab1' yet if statement is false]. I am using struts 2.0.14.




--- On Fri, 2/6/09, Wes Wannemacher <we...@wantii.com> wrote:

> From: Wes Wannemacher <we...@wantii.com>
> Subject: Re: How to use "s:include" param in s:if
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Received: Friday, February 6, 2009, 11:07 PM
> On Friday 06 February 2009 17:35:56 Struts Two wrote:
> > I have run out of options and I was hoping if someone
> can help me. I have
> > an include tag as follows:
> >
> > <s:include
> value="./includes/tabs.jsp">
> > 	<s:param name="tabId"
> value="%{'tab1'}" />
> > </s:include>
> >
> > In my tabs.jsp, I tried to do the following:
> >
> > <td <s:if test="%{#request.param.tabId ==
> 'tab1'}">class="on"
> >
> </s:if><s:else>class="off"</s:else>
> >
> >
> > But of no avail. Using ${param.tabId}, I can see the
> value of tablId. I
> > even tried [crazy ideas like]:
> >
> > <td <s:if test="%{${param.tabId} ==
> 'tab1'}">class="on"
> >
> </s:if><s:else>class="off"</s:else>
> >
> >
> > <td <s:if test="{${param.tabId} ==
> 'tab1'}">class="on"
> >
> </s:if><s:else>class="off"</s:else>
> >
> >
> > Refering to "Struts 2 in action" and
> "Struts 2 Design and programming" was
> > of no help.
> >
> > I would appreciate if anybody helps me on that.
> >
> > regards,
> >
> 
> Try - 
> 
> <s:if test="#parameters.tabId ==
> 'tab1'">
> 
> -Wes
> 
> -- 
> 
> Wes Wannemacher
> Author - Struts 2 In Practice 
> Includes coverage of Struts 2.1, Spring, JPA, JQuery,
> Sitemesh and more
> http://www.manning.com/wannemacher
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to use "s:include" param in s:if

Posted by Wes Wannemacher <we...@wantii.com>.
On Friday 06 February 2009 17:35:56 Struts Two wrote:
> I have run out of options and I was hoping if someone can help me. I have
> an include tag as follows:
>
> <s:include value="./includes/tabs.jsp">
> 	<s:param name="tabId" value="%{'tab1'}" />
> </s:include>
>
> In my tabs.jsp, I tried to do the following:
>
> <td <s:if test="%{#request.param.tabId == 'tab1'}">class="on"
> </s:if><s:else>class="off"</s:else> >
>
> But of no avail. Using ${param.tabId}, I can see the value of tablId. I
> even tried [crazy ideas like]:
>
> <td <s:if test="%{${param.tabId} == 'tab1'}">class="on"
> </s:if><s:else>class="off"</s:else> >
>
> <td <s:if test="{${param.tabId} == 'tab1'}">class="on"
> </s:if><s:else>class="off"</s:else> >
>
> Refering to "Struts 2 in action" and "Struts 2 Design and programming" was
> of no help.
>
> I would appreciate if anybody helps me on that.
>
> regards,
>

Try - 

<s:if test="#parameters.tabId == 'tab1'">

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org