Charles-Alexandre Sabourdin wrote:

I tryied to find answers form forum and within the archive but I never had answer so here is my probleme :

I am trying to do a developpement in JSP1.2 (XML) instead of JSP1.1 using tag %=% and %% instead of <%=..%> et <%..%>
I would like to change the style of div with an iteration:
Mycode is the following
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="1.2"
xmlns:tiles="/WEB-INF/struts-tiles.tld"
xmlns:bean="/WEB-INF/struts-bean.tld"
xmlns:html="/WEB-INF/struts-html.tld"
xmlns:logic="/WEB-INF/struts-logic.tld"


<jsp:scriptlet>
java.util.List l =
com.imko.schemnet.anomalie.db.AnomaliePeer.doSelectAllOrdered();
//java.util.List l = new java.util.Vector();
pageContext.setAttribute("lstAnomalie",l);
boolean grey = true;
String classUsed="anomalieGrey";
</jsp:scriptlet>

<div class="anomalieGen">
<jsp:expression>
classUsed
</jsp:expression>

<logic:iterate id="ano" name="lstAnomalie">
<div class="%=classUsed%"><!-- the probleme lay here -->
<bean:define id="cat" name="ano" property="idCategorie"/>
<jsp:scriptlet>
if(grey){
classUsed="\"anomalieGrey\"";
grey = false;
}else{
grey = true;
classUsed="\"anomalieWhite\"";
}
</jsp:scriptlet>
...
</div>
</logic:iterate>
</div>
</jsp:root>
Reference (http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html) says to remplace <%=%> par %=% .
but it only work with taglig


<html:img class="%=classUsed%"> works but
<div class="%=classUsed%">-- does not.

Yes. This is right. %=% expressions can be used only in attributes in custom tags, not html tags.


I solve the same problem with following (may be little ugly) expression:
<![CDATA[<div class="]]><jsp:expression>classUsed</jsp:expression><![CDATA[">]]>
div tag body
<![CDATA[</div>]]>


Or create yor own taglib :)

best regards,
Konstantin


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to