struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "starki78" <stark...@libero.it>
Subject Re: Strange Problem with logic:equals!
Date Fri, 07 Oct 2005 11:49:49 GMT
Thank you all for your help!
Now I've understood the problem


---------- Initial Header -----------

>From      : "Nicolas De Loof" nicolas.deloof@capgemini.com
To          : "Struts Users Mailing List" user@struts.apache.org
Cc          : 
Date      : Fri, 07 Oct 2005 11:07:16 +0200
Subject : Re: Strange Problem with logic:equals!







> 
> <bean:define> creates BOTH 
> - a script variable (a Java variable you can use in <% ... %> java blocs)
> - a bean in specified scope (defaults to page)
> 
> 
> So you have a "myBeanValue" variable set to 1 and a "myBeanValue" String 
> put into page scope.
> 
> <% myBeanValue = "2"; %> changes value of script variable. myBeanValue bean in
page scope is not impacted
> 
> <logic:equal name="myBeanValue" value="1"> checks the bean in page scope, witch
equals "1".
> 
> To solve this, you may :
> 
> - use scriptlet, not logic tag, to check script variables (NOT RECOMENDED) :
>   <% if ("1".equals(myBeanValue)) { %> ...<% } %>
> 
> - reuse <bean:define> to change myBeanValue, but be carreful some servlet container
don't accept multiple use of this tag with the same id, -> so NOT RECOMENDED
> 
> - not use scriptlets anymore ! Change myBeanValue by using tags, especially use EL struts
tags and JSTL :
>   <c:set var="myBeanValue" value="1"/>
>   ...
>   <c:set var="myBeanValue" value="2"/>
>   ...
>   <c:choose>
>     <c:when test="${myBeanValue == '1'}">...</c:when>
>     <c:otherwise>...</c:otherwise>
>  </c:choose>
> 
> 
> Nico.
> 
> 
> Aymeric Alibert a écrit :
> 
> >Do you have the struts-bean tag library defined in your jsp:?
> >Something like <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> >
> >Aymeric.
> >
> >On 10/7/05, starki78 <starki78@libero.it> wrote:
> >  
> >
> >>Hi, we have a strange Problem
> >>with logic:equal
> >>
> >>Look at the following code:
> >>
> >>
> >>//--> first we create a bean
> >>
> >><bean:define id="myBeanValue" value="1"/>
> >>
> >>//--> changing the value is this possible in the way???
> >>
> >><% myBeanValue = "2"; %>
> >>
> >>
> >>// tests with the logic:equals tags
> >>
> >><logic:equal name="myBeanValue" value="1">
> >><br>is equal</br>
> >></logic:equal>
> >>
> >><logic:notEqual name="myBeanValue" value="1">
> >><br>is notequal</br>
> >></logic:notEqual>
> >>
> >>
> >>After running the jsp we are getting the result= is equal!!!
> >>
> >>But Why?? Is it not possible to redefine the variable
> >>in the way that we try this in the example!
> >>What makes us even more worried is that
> >>when we debug, it neither jumps in the first nor
> >>in the second logic:equal tag.
> >>
> >>Please help me!
> >>
> >>Nice Greetings
> >>Starki
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >>    
> >>
> >
> >  
> >
> 
> This message contains information that may be privileged or confidential and is the property
of the Capgemini Group. It is intended only for the person to whom it is addressed. If you
are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,
 distribute, or use this message or any part thereof. If you receive this  message in error,
please notify the sender immediately and delete all  copies of this message.
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message