You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Griffith, Michael *" <Mi...@fda.hhs.gov> on 2009/02/06 21:19:14 UTC

Can I use a Parameter in result definition?

Hello all...
 
Does anyone know if it is possible to use a parameter in my
action/result definition:

I want to use the package name in the result definition
<package name="component" extends="base-package" namespace="/component">

	<action...
		<result name="success"
type="tiles">view-{0).panel</result> <!-- SUBSTITUTE component for {0}
-->
	</action>
</package>

Would become:
<package name="component" extends="base-package" namespace="/component">

	<action...
		<result name="success"
type="tiles">view-component.panel</result>
	</action>
</package>

Is this possible?

Thanks in advance, 
MG

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


Re: Can I use a Parameter in result definition?

Posted by Dale Newfield <da...@newfield.org>.
Musachy Barroso wrote:
>> Should we change the documentation?  (Is it documented anywhere other than
>> the javadocs?)  Should we include that change in the upgrade instructions?
> 
> Feel free to update the wiki.

I added a bit to the upgrade instructions.  Changing the javadoc 
requires svn commit privileges, though...

-Dale

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


Re: Can I use a Parameter in result definition?

Posted by Musachy Barroso <mu...@gmail.com>.
On Fri, Feb 6, 2009 at 5:51 PM, Dale Newfield <da...@newfield.org> wrote:
> Musachy Barroso wrote:
>>>
>>> Yes.  You can include OGNL there (except it uses the JSTL ${} syntax
>>> instead
>>> of OGNL %{} syntax for a reason I've never understood):
>>
>> I think we fixed that already.
>
> I just looked in the source and see that it should now work with either.  I
> changed my current app and it worked!
>
> Should we change the documentation?  (Is it documented anywhere other than
> the javadocs?)  Should we include that change in the upgrade instructions?
>

Feel free to update the wiki.

> Now that you've looked at this in more detail, assuming anyone ever gets
> alternative scripting languages working, does the possibility of making them
> all work and be selectable based on the character %{} for ognl, ${} for
> jstl, #{} for mvel, etc. seem possible?

That wouldn't be hard.

musachy
-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Can I use a Parameter in result definition?

Posted by Dale Newfield <da...@newfield.org>.
Musachy Barroso wrote:
>> Yes.  You can include OGNL there (except it uses the JSTL ${} syntax instead
>> of OGNL %{} syntax for a reason I've never understood):
> 
> I think we fixed that already.

I just looked in the source and see that it should now work with either. 
   I changed my current app and it worked!

Should we change the documentation?  (Is it documented anywhere other 
than the javadocs?)  Should we include that change in the upgrade 
instructions?

Now that you've looked at this in more detail, assuming anyone ever gets 
alternative scripting languages working, does the possibility of making 
them all work and be selectable based on the character %{} for ognl, ${} 
for jstl, #{} for mvel, etc. seem possible?

-Dale


---------------------------------------------------------------------
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


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

Posted by Struts Two <st...@yahoo.ca>.
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: Can I use a Parameter in result definition?

Posted by Musachy Barroso <mu...@gmail.com>.
> Yes.  You can include OGNL there (except it uses the JSTL ${} syntax instead
> of OGNL %{} syntax for a reason I've never understood):
>

I think we fixed that already.

musachy
-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


RE: Can I use a Parameter in result definition?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Dave, 

Thanks for the reply, and the suggestion~

Cheers!
MG 

-----Original Message-----
From: Dale Newfield [mailto:dale@newfield.org] 
Sent: Friday, February 06, 2009 5:23 PM
To: Struts Users Mailing List
Subject: Re: Can I use a Parameter in result definition?

Griffith, Michael * wrote:
> Cool, but looking at the doc, it looks like the only place I can 
> declare a parm is in the result tag?

It looked like the only place you wanted to use this substitution was in
a result tag.  I didn't notice what value it was you wanted until now.

The action is on top of the value stack when that's evaluated, and there
should be some way to get to that info from there...so if you make your
BaseAction class include a getNamespace() method that does the right
thing, you can say %{namespace} in the struts.xml like you asked.

I've got to sign off, so I'm not providing the magic incantation to get
this from the action, but I bet there's some way to get it.  I don't see
it right now, but I thought there used to be an ActionMappingAware
interface, for example...

-Dale

---------------------------------------------------------------------
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


Re: Can I use a Parameter in result definition?

Posted by Dale Newfield <da...@newfield.org>.
Griffith, Michael * wrote:
> Cool, but looking at the doc, it looks like the only place I can declare
> a parm is in the result tag?

It looked like the only place you wanted to use this substitution was in 
a result tag.  I didn't notice what value it was you wanted until now.

The action is on top of the value stack when that's evaluated, and there 
should be some way to get to that info from there...so if you make your 
BaseAction class include a getNamespace() method that does the right 
thing, you can say %{namespace} in the struts.xml like you asked.

I've got to sign off, so I'm not providing the magic incantation to get 
this from the action, but I bet there's some way to get it.  I don't see 
it right now, but I thought there used to be an ActionMappingAware 
interface, for example...

-Dale

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


RE: Can I use a Parameter in result definition?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Cool, but looking at the doc, it looks like the only place I can declare
a parm is in the result tag?  

Something like this:
<result name="success" type="tiles">view-{packageName}.panel</result>

How do I declare the variable at the package level so I don't have to
redeclare each action and result?

MG

-----Original Message-----
From: Dale Newfield [mailto:dale@newfield.org] 
Sent: Friday, February 06, 2009 2:25 PM
To: Struts Users Mailing List
Subject: Re: Can I use a Parameter in result definition?

Griffith, Michael * wrote:
> Does anyone know if it is possible to use a parameter in my 
> action/result definition:

Yes.  You can include OGNL there (except it uses the JSTL ${} syntax
instead of OGNL %{} syntax for a reason I've never understood):

http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/d
ispatcher/StrutsResultSupport.html

-Dale

---------------------------------------------------------------------
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


Re: Can I use a Parameter in result definition?

Posted by Dale Newfield <da...@newfield.org>.
Griffith, Michael * wrote:
> Does anyone know if it is possible to use a parameter in my
> action/result definition:

Yes.  You can include OGNL there (except it uses the JSTL ${} syntax 
instead of OGNL %{} syntax for a reason I've never understood):

http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/dispatcher/StrutsResultSupport.html

-Dale

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