freshWoWer
freshWoWer

Reputation: 64239

struts checkbox

I am trying to set the fieldValue of the check box to a value I got from the property tag.

I am having trouble with the syntax.

This is what I have tried:

<s:form id="myForm" method="post" action="removeUser" enctype="multipart/form-data">
     <s:iterator value="myList">
        <tr>
            <td><s:property value="id"/></td> 
            <td><s:property value="name"/></td> 
            <td><s:property value="email"/></td>
            <td><s:checkbox label="delete" name="delete" fieldValue="<s:property value='id'/>"/></td>
        </tr>
    </s:iterator>

    <s:submit id="saveForm" value="Delete users"></s:submit>
  </s:form>

However, it keeps on returning me true as the fieldValue

Can someone familiar with struts please help me?

Thanks

Upvotes: 2

Views: 3159

Answers (2)

rohan
rohan

Reputation: 557

Try doing:

fieldValue="<s:property value= "${id }"  />"

or

fieldValue="<s:property value=<c:out value="${id }"/>   />"

this will require:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Upvotes: 0

Alexandru Luchian
Alexandru Luchian

Reputation: 2780

I don't think you can do that:

<s:checkbox label="delete" name="delete" fieldValue="<s:property value='id'/>"/>

fieldValue expects a OGNL expression. I did some Struts, not too much, you could try:

fieldValue="%{id}"

Upvotes: 1

Related Questions