Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

passing c:forEach value to custom tag as attribute?

 
Mallik Avula
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all
i just overcome the last query
but now i have another problem
that is, i have to pass the value of <c:forEach> value to custom tag
this is my code:
----------------------------------------------------------------
<%
Vector rs = (Vector)request.getAttribute("ROLESERVICES");

%>

<c:forEach items="${SERVICES}" var="services">
<tr>
<td class="rightsubheading1" colspan="2">
<aims:ex value='${services.serviceId}' object="<%=rs%>"/>
</td>
<td class="leftsubheading1" colspan="2"><cut value="${services.serviceName}"/></td>
</tr>
</c:forEach>
----------------------------------------------------------
when i print the value from tag handler class i am getting
${services.serviceId}
but i wish to send the value..

let me know how to pass this value

warm regards
Mallik
 
Kamesh Rao
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Report post to moderator
Use org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager classes evaluate method as defined below

public static Object evaluate(String attributeName,
String expression,
Class expectedType,
Tag tag,
PageContext pageContext);
 
Hassan Ashmawy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have a problem like the problem of yours :-
// ALL_EMPS is a Vector of (EmpDTO) in the session
<c:forEach varStatus="status" var="EmpDTO" items="${sessionScope.ALL_EMPS}">
<tr>
<td align="right" bgcolor="#ffffff">
Emp No. : <cut value='${status.index}' />
<cut value="${EmpDTO.FirstName}" />
<cut value="${EmpDTO}" />
</td>
</tr>
</c:forEach>

1) when i use the first (c : out) i get the following error: An error occurred while evaluating custom action attribute "value" with value "${EmpDTO.FirstName}": Unable to find a value for "FirstName" in object of class "b2c.EmpDTO" using operator "." (null)
2) when i use the second (c : out) i get - ofcourse - something like that : b2c.EmpDTO@1854d1f which the the class name and the hash no. of the current that object!!!

any help expert-guys ??
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Report post to moderator
Next time start your own post instead of resurrecting an old one.

<cut value="${EmpDTO.FirstName}" />

If your bean has getFirstName() and setFirstName(), then you should be using EmpDTO.firstName with lowercase f.
    Bookmark Topic Watch Topic
  • New Topic