You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mech <me...@rz.fh-augsburg.de> on 2003/01/24 14:01:01 UTC

, problem with rt expr values

Hi,

I'm using Struts 1.1b and want to use <logic:equal> to compare values
and I'm totally stuck when I try to use no constant for the value
attribute...

My code this:

I have a formbean named "ListExperimentForm" with a getter method
"getTopics()" to return a collection of Objects each containing a
private int member variable "topicid"

I would like to check inside the iteration if the topicid matched a
runtime expression. That could be a get parameter or any scripting
variable. But I don't get it work. 

<logic:equal name="topicsList" property="topicid" value="5"> is fine...
but I can't use a constant value attribute, of course.


If I for example try:

<% int myint = 5; %>
<logic:iterate id="topicsList" name="ListExperimentsForm"
property="topics">
	<logic:equal name="topicsList" property="topicid" value="<%
=myint %>">
		DOSOMETHINGCONDITIONAL
	</logic:equal>
	DOSOMETHING
</logic>

nothing happens if topicid == 5...


I guess this is because of:

  /* ----  logic:equal ---- */
    org.apache.struts.taglib.logic.EqualTag _jspx_th_logic_equal_3 =
(org.apache.struts.taglib.logic.EqualTag)
_jspx_tagPool_logic_equal_value_property_name.get(org.apache.struts.tagl
ib.logic.EqualTag.class);
    _jspx_th_logic_equal_3.setPageContext(pageContext);
    _jspx_th_logic_equal_3.setParent(_jspx_th_logic_iterate_0);
    _jspx_th_logic_equal_3.setName("topicsList");
    _jspx_th_logic_equal_3.setProperty("topicid");
    _jspx_th_logic_equal_3.setValue("<% =myint %>");

So "topicid" is not compared to the value of myint, instead it's
compared to the string "<% =myint %>"...

I'm confused. Especially after reading examples like:
http://j2ee.masslight.com/Chapter5.html

I can't see the difference... How can I solve this issue with runtime
expressions?
I've tried it with other struts tags, too.... Whenever I need to put a
scriptlet variable into e.g. a value attribute of a tag, nothing works
as expected.


Thanks for any hint... I'm getting gray hair and think about using
scriptlets instead of struts tags, if I don't find out what's wrong
soon...
Michael


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: , problem with rt expr values

Posted by mech <me...@rz.fh-augsburg.de>.
Thanks for saving my last hairs... that put me on track.

But actually I got a compiler error this time:

cannot resolve symbol symbol : method setValue (int) location: class
org.apache.struts.taglib.logic.EqualTag _jspx_th_logic_equal_3.setValue(
myint ); ^ 1 error 


Obviously there is no setValue() method for this bean:equal tag which
could take integers.
After I changed to String:

<% String mystr = "5" %>
<logic:equal name="topicsList" property="topicid" value="<%= mystr%>">
</logic:equal>

it finally worked... Guess you just used string constants?! 
Anyway if I type convert like <%= Integer.toString(myint) %> beforehand,
it's fine, too...

Thx again.
Michael

P.S. stupid "space" mistake and type conversion costing 2 hours or
more... 

> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
> Sent: Freitag, 24. Januar 2003 14:23
> To: Struts Users Mailing List; mech@informatik.fh-augsburg.de
> Subject: Re: <bean:define>, <logic:equal> problem with rt expr values
> 
> 
> You typed <% =myint %> instead of <%= myint %> !
> 
> I used this a lot of time :
> 
> <logic:equal name="topicsList"
>              property="topicid"
>              value="<%= MyClass.CONSTANT_VALUE %>">
>      foo
> </logic:equal>
> 
> Nico.
> 
> > Hi,
> >
> > I'm using Struts 1.1b and want to use <logic:equal> to 
> compare values 
> > and I'm totally stuck when I try to use no constant for the value 
> > attribute...
> >
> > My code this:
> >
> > I have a formbean named "ListExperimentForm" with a getter method 
> > "getTopics()" to return a collection of Objects each containing a 
> > private int member variable "topicid"
> >
> > I would like to check inside the iteration if the topicid matched a 
> > runtime expression. That could be a get parameter or any scripting 
> > variable. But I don't get it work.
> >
> > <logic:equal name="topicsList" property="topicid" value="5"> is 
> > fine... but I can't use a constant value attribute, of course.
> >
> >
> > If I for example try:
> >
> > <% int myint = 5; %>
> > <logic:iterate id="topicsList" name="ListExperimentsForm" 
> > property="topics"> <logic:equal name="topicsList" 
> property="topicid" 
> > value="<% =myint %>">
> > DOSOMETHINGCONDITIONAL
> > </logic:equal>
> > DOSOMETHING
> > </logic>
> >
> > nothing happens if topicid == 5...
> >
> >
> > I guess this is because of:
> >
> >   /* ----  logic:equal ---- */
> >     org.apache.struts.taglib.logic.EqualTag _jspx_th_logic_equal_3 =
> > (org.apache.struts.taglib.logic.EqualTag)
> > 
> _jspx_tagPool_logic_equal_value_property_name.get(org.apache.struts.ta
> > gl
> > ib.logic.EqualTag.class);
> >     _jspx_th_logic_equal_3.setPageContext(pageContext);
> >     _jspx_th_logic_equal_3.setParent(_jspx_th_logic_iterate_0);
> >     _jspx_th_logic_equal_3.setName("topicsList");
> >     _jspx_th_logic_equal_3.setProperty("topicid");
> >     _jspx_th_logic_equal_3.setValue("<% =myint %>");
> >
> > So "topicid" is not compared to the value of myint, instead it's 
> > compared to the string "<% =myint %>"...
> >
> > I'm confused. Especially after reading examples like: 
> > http://j2ee.masslight.com/Chapter5.html
> >
> > I can't see the difference... How can I solve this issue 
> with runtime 
> > expressions? I've tried it with other struts tags, too.... 
> Whenever I 
> > need to put a scriptlet variable into e.g. a value 
> attribute of a tag, 
> > nothing works as expected.
> >
> >
> > Thanks for any hint... I'm getting gray hair and think about using 
> > scriptlets instead of struts tags, if I don't find out what's wrong 
> > soon... Michael
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: , problem with rt expr values

Posted by Nicolas De Loof <ni...@cgey.com>.
You typed <% =myint %> instead of <%= myint %> !

I used this a lot of time :

<logic:equal name="topicsList"
             property="topicid"
             value="<%= MyClass.CONSTANT_VALUE %>">
     foo
</logic:equal>

Nico.

> Hi,
>
> I'm using Struts 1.1b and want to use <logic:equal> to compare values
> and I'm totally stuck when I try to use no constant for the value
> attribute...
>
> My code this:
>
> I have a formbean named "ListExperimentForm" with a getter method
> "getTopics()" to return a collection of Objects each containing a
> private int member variable "topicid"
>
> I would like to check inside the iteration if the topicid matched a
> runtime expression. That could be a get parameter or any scripting
> variable. But I don't get it work.
>
> <logic:equal name="topicsList" property="topicid" value="5"> is fine...
> but I can't use a constant value attribute, of course.
>
>
> If I for example try:
>
> <% int myint = 5; %>
> <logic:iterate id="topicsList" name="ListExperimentsForm"
> property="topics">
> <logic:equal name="topicsList" property="topicid" value="<%
> =myint %>">
> DOSOMETHINGCONDITIONAL
> </logic:equal>
> DOSOMETHING
> </logic>
>
> nothing happens if topicid == 5...
>
>
> I guess this is because of:
>
>   /* ----  logic:equal ---- */
>     org.apache.struts.taglib.logic.EqualTag _jspx_th_logic_equal_3 =
> (org.apache.struts.taglib.logic.EqualTag)
> _jspx_tagPool_logic_equal_value_property_name.get(org.apache.struts.tagl
> ib.logic.EqualTag.class);
>     _jspx_th_logic_equal_3.setPageContext(pageContext);
>     _jspx_th_logic_equal_3.setParent(_jspx_th_logic_iterate_0);
>     _jspx_th_logic_equal_3.setName("topicsList");
>     _jspx_th_logic_equal_3.setProperty("topicid");
>     _jspx_th_logic_equal_3.setValue("<% =myint %>");
>
> So "topicid" is not compared to the value of myint, instead it's
> compared to the string "<% =myint %>"...
>
> I'm confused. Especially after reading examples like:
> http://j2ee.masslight.com/Chapter5.html
>
> I can't see the difference... How can I solve this issue with runtime
> expressions?
> I've tried it with other struts tags, too.... Whenever I need to put a
> scriptlet variable into e.g. a value attribute of a tag, nothing works
> as expected.
>
>
> Thanks for any hint... I'm getting gray hair and think about using
> scriptlets instead of struts tags, if I don't find out what's wrong
> soon...
> Michael
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>