Quantcast

How to write variable in a Struts 2 tag?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to write variable in a Struts 2 tag?

bugs_
I need rewrite jsp page from Struts 1 to Struts 2.

In Strust 1 is in the page something like this:
<% String variable = ... %>
<html:hidden property="foo" value="<%= variable %>"/>

I tried to rewrite it in Struts 2:
<% String variable = ... %>
<s:hidden name="foo" value="<%= variable %>" />
but this doesn't work. It return an error message: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"

I really don't know how to access variable in a Struts 2 tag?

I tried to read Struts 2 documentation, but I didn't find solution.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

Musachy Barroso
http://answers.google.com/answers/threadview?id=371241

musachy

On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:

>
>  I need rewrite jsp page from Struts 1 to Struts 2.
>
>  In Strust 1 is in the page something like this:
>  <% String variable = ... %>
>  <html:hidden property="foo" value="<%= variable %>"/>
>
>  I tried to rewrite it in Struts 2:
>  <% String variable = ... %>
>  <s:hidden name="foo" value="<%= variable %>" />
>  but this doesn't work. It return an error message: "According to TLD or
>  attribute directive in tag file, attribute value does not accept any
>  expressions"
>
>  I really don't know how to access variable in a Struts 2 tag?
>
>  I tried to read Struts 2 documentation, but I didn't find solution.
>  --
>  View this message in context: http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html
>  Sent from the Struts - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [hidden email]
>  For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

newton.dave
--- Musachy Barroso <[hidden email]> wrote:
> http://answers.google.com/answers/threadview?id=371241

Wow, you're like Meta-Google.

Dave

> On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:
> >
> >  I need rewrite jsp page from Struts 1 to Struts 2.
> >
> >  In Strust 1 is in the page something like this:
> >  <% String variable = ... %>
> >  <html:hidden property="foo" value="<%= variable %>"/>
> >
> >  I tried to rewrite it in Struts 2:
> >  <% String variable = ... %>
> >  <s:hidden name="foo" value="<%= variable %>" />
> >  but this doesn't work. It return an error message: "According to TLD or
> >  attribute directive in tag file, attribute value does not accept any
> >  expressions"
> >
> >  I really don't know how to access variable in a Struts 2 tag?
> >
> >  I tried to read Struts 2 documentation, but I didn't find solution.
> >  --
> >  View this message in context:
>
http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html

> >  Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: [hidden email]
> >  For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

Musachy Barroso
I am trying to let people know about this new cool google thingy, that
finds stuff for you :)

musachy

On Tue, Mar 11, 2008 at 2:35 PM, Dave Newton <[hidden email]> wrote:

> --- Musachy Barroso <[hidden email]> wrote:
>  > http://answers.google.com/answers/threadview?id=371241
>
>  Wow, you're like Meta-Google.
>
>  Dave
>
>
>
>  > On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:
>  > >
>  > >  I need rewrite jsp page from Struts 1 to Struts 2.
>  > >
>  > >  In Strust 1 is in the page something like this:
>  > >  <% String variable = ... %>
>  > >  <html:hidden property="foo" value="<%= variable %>"/>
>  > >
>  > >  I tried to rewrite it in Struts 2:
>  > >  <% String variable = ... %>
>  > >  <s:hidden name="foo" value="<%= variable %>" />
>  > >  but this doesn't work. It return an error message: "According to TLD or
>  > >  attribute directive in tag file, attribute value does not accept any
>  > >  expressions"
>  > >
>  > >  I really don't know how to access variable in a Struts 2 tag?
>  > >
>  > >  I tried to read Struts 2 documentation, but I didn't find solution.
>  > >  --
>  > >  View this message in context:
>  >
>  http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html
>  > >  Sent from the Struts - User mailing list archive at Nabble.com.
>  > >
>  > >
>  > >  ---------------------------------------------------------------------
>  > >  To unsubscribe, e-mail: [hidden email]
>  > >  For additional commands, e-mail: [hidden email]
>  > >
>  > >
>  >
>  >
>  >
>  > --
>  > "Hey you! Would you help me to carry the stone?" Pink Floyd
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [hidden email]
>  > For additional commands, e-mail: [hidden email]
>  >
>  >
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [hidden email]
>  For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

newton.dave
--- Musachy Barroso <[hidden email]> wrote:
> I am trying to let people know about this new cool google thingy,
> that finds stuff for you :)

Riiiiight. Even if it did it'll never catch on.

Dave

>
> musachy
>
> On Tue, Mar 11, 2008 at 2:35 PM, Dave Newton <[hidden email]> wrote:
> > --- Musachy Barroso <[hidden email]> wrote:
> >  > http://answers.google.com/answers/threadview?id=371241
> >
> >  Wow, you're like Meta-Google.
> >
> >  Dave
> >
> >
> >
> >  > On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:
> >  > >
> >  > >  I need rewrite jsp page from Struts 1 to Struts 2.
> >  > >
> >  > >  In Strust 1 is in the page something like this:
> >  > >  <% String variable = ... %>
> >  > >  <html:hidden property="foo" value="<%= variable %>"/>
> >  > >
> >  > >  I tried to rewrite it in Struts 2:
> >  > >  <% String variable = ... %>
> >  > >  <s:hidden name="foo" value="<%= variable %>" />
> >  > >  but this doesn't work. It return an error message: "According to
> TLD or
> >  > >  attribute directive in tag file, attribute value does not accept
> any
> >  > >  expressions"
> >  > >
> >  > >  I really don't know how to access variable in a Struts 2 tag?
> >  > >
> >  > >  I tried to read Struts 2 documentation, but I didn't find solution.
> >  > >  --
> >  > >  View this message in context:
> >  >
> >
>
http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html

> >  > >  Sent from the Struts - User mailing list archive at Nabble.com.
> >  > >
> >  > >
> >  > >
> ---------------------------------------------------------------------
> >  > >  To unsubscribe, e-mail: [hidden email]
> >  > >  For additional commands, e-mail: [hidden email]
> >  > >
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >  >
> >  > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: [hidden email]
> >  > For additional commands, e-mail: [hidden email]
> >  >
> >  >
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: [hidden email]
> >  For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

bugs_
In reply to this post by Musachy Barroso
But
<%
  // declare or construct your variable...
  String title="My page";
  // set the variable in the page context under the variable name "title"
  pageContext.setAttribute("title",title);
%>
<s:hidden name="foo" value='${title}' />

This return the same error. Could you write me here any simple working example?




Musachy Barroso wrote
http://answers.google.com/answers/threadview?id=371241

musachy

On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <bugsmail@centrum.cz> wrote:
>
>  I need rewrite jsp page from Struts 1 to Struts 2.
>
>  In Strust 1 is in the page something like this:
>  <% String variable = ... %>
>  <html:hidden property="foo" value="<%= variable %>"/>
>
>  I tried to rewrite it in Struts 2:
>  <% String variable = ... %>
>  <s:hidden name="foo" value="<%= variable %>" />
>  but this doesn't work. It return an error message: "According to TLD or
>  attribute directive in tag file, attribute value does not accept any
>  expressions"
>
>  I really don't know how to access variable in a Struts 2 tag?
>
>  I tried to read Struts 2 documentation, but I didn't find solution.
>  --
>  View this message in context: http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html
>  Sent from the Struts - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>



--
"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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

Laurie Harper
If you're using 2.0.11.1, Struts tags do not allow JSTL expressions. You
need to use OGNL instead. I don't recall the OGNL syntax for accessing
page-scope variables, but it's probably something like %{title}, or
%{#title}. Check the OGNL documentation to be sure if someone else
doesn't chime in here.

L.

bugs_ wrote:

> But
> <%
>   // declare or construct your variable...
>   String title="My page";
>   // set the variable in the page context under the variable name "title"
>   pageContext.setAttribute("title",title);
> %>
> <s:hidden name="foo" value='${title}' />
>
> This return the same error. Could you write me here any simple working
> example?
>
>
>
>
>
> Musachy Barroso wrote:
>> http://answers.google.com/answers/threadview?id=371241
>>
>> musachy
>>
>> On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:
>>>  I need rewrite jsp page from Struts 1 to Struts 2.
>>>
>>>  In Strust 1 is in the page something like this:
>>>  <% String variable = ... %>
>>>  <html:hidden property="foo" value="<%= variable %>"/>
>>>
>>>  I tried to rewrite it in Struts 2:
>>>  <% String variable = ... %>
>>>  <s:hidden name="foo" value="<%= variable %>" />
>>>  but this doesn't work. It return an error message: "According to TLD or
>>>  attribute directive in tag file, attribute value does not accept any
>>>  expressions"
>>>
>>>  I really don't know how to access variable in a Struts 2 tag?
>>>
>>>  I tried to read Struts 2 documentation, but I didn't find solution.
>>>  --
>>>  View this message in context:
>>> http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html
>>>  Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>>  ---------------------------------------------------------------------
>>>  To unsubscribe, e-mail: [hidden email]
>>>  For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

newton.dave
#attr.title will search through the various scopes.

--- Laurie Harper <[hidden email]> wrote:

> If you're using 2.0.11.1, Struts tags do not allow JSTL expressions. You
> need to use OGNL instead. I don't recall the OGNL syntax for accessing
> page-scope variables, but it's probably something like %{title}, or
> %{#title}. Check the OGNL documentation to be sure if someone else
> doesn't chime in here.
>
> L.
>
> bugs_ wrote:
> > But
> > <%
> >   // declare or construct your variable...
> >   String title="My page";
> >   // set the variable in the page context under the variable name "title"
> >   pageContext.setAttribute("title",title);
> > %>
> > <s:hidden name="foo" value='${title}' />
> >
> > This return the same error. Could you write me here any simple working
> > example?
> >
> >
> >
> >
> >
> > Musachy Barroso wrote:
> >> http://answers.google.com/answers/threadview?id=371241
> >>
> >> musachy
> >>
> >> On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <[hidden email]> wrote:
> >>>  I need rewrite jsp page from Struts 1 to Struts 2.
> >>>
> >>>  In Strust 1 is in the page something like this:
> >>>  <% String variable = ... %>
> >>>  <html:hidden property="foo" value="<%= variable %>"/>
> >>>
> >>>  I tried to rewrite it in Struts 2:
> >>>  <% String variable = ... %>
> >>>  <s:hidden name="foo" value="<%= variable %>" />
> >>>  but this doesn't work. It return an error message: "According to TLD
> or
> >>>  attribute directive in tag file, attribute value does not accept any
> >>>  expressions"
> >>>
> >>>  I really don't know how to access variable in a Struts 2 tag?
> >>>
> >>>  I tried to read Struts 2 documentation, but I didn't find solution.
> >>>  --
> >>>  View this message in context:
> >>>
>
http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html

> >>>  Sent from the Struts - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>>  ---------------------------------------------------------------------
> >>>  To unsubscribe, e-mail: [hidden email]
> >>>  For additional commands, e-mail: [hidden email]
> >>>
> >>>
> >>
> >>
> >> --
> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

bugs_
%{#attr.varName} works fine. Thank you everybody
I am so happy :-D
I must find some good tutorial for ognl



newton.dave wrote
#attr.title will search through the various scopes.

--- Laurie Harper <laurie@holoweb.net> wrote:
> If you're using 2.0.11.1, Struts tags do not allow JSTL expressions. You
> need to use OGNL instead. I don't recall the OGNL syntax for accessing
> page-scope variables, but it's probably something like %{title}, or
> %{#title}. Check the OGNL documentation to be sure if someone else
> doesn't chime in here.
>
> L.
>
> bugs_ wrote:
> > But
> > <%
> >   // declare or construct your variable...
> >   String title="My page";
> >   // set the variable in the page context under the variable name "title"
> >   pageContext.setAttribute("title",title);
> > %>
> > <s:hidden name="foo" value='${title}' />
> >
> > This return the same error. Could you write me here any simple working
> > example?
> >
> >
> >
> >
> >
> > Musachy Barroso wrote:
> >> http://answers.google.com/answers/threadview?id=371241
> >>
> >> musachy
> >>
> >> On Tue, Mar 11, 2008 at 1:39 PM, bugs_ <bugsmail@centrum.cz> wrote:
> >>>  I need rewrite jsp page from Struts 1 to Struts 2.
> >>>
> >>>  In Strust 1 is in the page something like this:
> >>>  <% String variable = ... %>
> >>>  <html:hidden property="foo" value="<%= variable %>"/>
> >>>
> >>>  I tried to rewrite it in Struts 2:
> >>>  <% String variable = ... %>
> >>>  <s:hidden name="foo" value="<%= variable %>" />
> >>>  but this doesn't work. It return an error message: "According to TLD
> or
> >>>  attribute directive in tag file, attribute value does not accept any
> >>>  expressions"
> >>>
> >>>  I really don't know how to access variable in a Struts 2 tag?
> >>>
> >>>  I tried to read Struts 2 documentation, but I didn't find solution.
> >>>  --
> >>>  View this message in context:
> >>>
>
http://www.nabble.com/How-to-write-variable-in-a-Struts-2-tag--tp15981156p15981156.html
> >>>  Sent from the Struts - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>>  ---------------------------------------------------------------------
> >>>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>  For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >> "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
> >>
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

newton.dave
--- bugs_ <[hidden email]> wrote:
> I must find some good tutorial for ognl

http://struts.apache.org/2.x/docs/ognl.html
http://struts.apache.org/2.x/docs/ognl-basics.html

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to write variable in a Struts 2 tag?

javajunkie
newton.dave wrote
--- bugs_ <bugsmail@centrum.cz> wrote:
> I must find some good tutorial for ognl

http://struts.apache.org/2.x/docs/ognl.html
http://struts.apache.org/2.x/docs/ognl-basics.html

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html

Dave


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

This was really annoying me, and your quote made me read OGNL doco's.  Worked really well, thanks.

Rod

Loading...