Discussions

Web tier: servlets, JSP, Web frameworks: Checkbox with displaytag

  1. Checkbox with displaytag (5 messages)

    I am using Struts 1.2.7 and displaytag to display a list of objects. For example, I have an ArrayList (methodList) of objects (Method) that I need to display. For each row, I need to include a checkbox so that the user can select multiple records.

    Here is an excerpt of the JSP code -

    <html:form action="/search.do" method="post">
    <display:table name="methodList" requestURI="" sort="list" class="results" id="table1">
    <display:column title="<input type='checkbox' name='selectall' />" class="results"><html:checkbox property="methodName"></display:column>
    <display:column property="methodName" title="Method ID" sortable="true" width="80" class="results"/>
    <display:column property="methodDesc" title="Method Desc" width="120" sortable="true" class="results"/>
    <display:column property="status" title="Status" width="80" sortable="true" class="results"/>
    </display:table>
    </html:form>

    When I execute this page, it returns a blank page and the following error log -

    javax.servlet.ServletException: No getter method for property methodName of bean

    How do I pass a value from the html:textbox tag?

    Threaded Messages (5)

  2. Checkbox WITHOUT displaytag[ Go to top ]

    I tried to implement checkbox without the displaytag and still ran into problems. Here is my code snippet -

    <html:form action="/search.do" method="post">
    <logic:iterate id="method" name="methodList" type="com.test.portal.projects.Method">
    <table class="results" id="table1">
    <tr>
    <td width="10" class="sortable"><html:checkbox property="control" value="<%=method.getScheduleID()%>"/></td>
    <td width="80" class="sortable"><bean:write name="method" property="methodName"/></td>
    <td width="120" class="sortable"><bean:write name="method" property="methodDesc"/></td>
    <td width="80" class="sortable"><bean:write name="method" property="acodeDesc"/></td>
    </tr>
    </table>
    </logic:iterate>
    </html:form>

    I get a blank page and the following error log -

    javax.servlet.jsp.JspException: ServletException in 'WEB-INF/user/SampleDetails.jsp': No getter method for property control of bean org.apache.struts.taglib.html.BEAN

    What's happening here?
  3. Checkbox WITHOUT displaytag[ Go to top ]

    when you use property attribute (in your case "control") of HTML form elements, Struts tries to invoke getControl method of the FormBean associated to the Action.

    If you have defined this method "getControl" in the Objects of methodList then your you have to use the id along with the property.

    <logic:iterate id="method" name="methodList" type="com.test.portal.projects.Method">
    <html:checkbox id="method" property="control" />

    The action search.do is mapped to some Actionform in your struts-config.xml
  4. Checkbox with displaytag[ Go to top ]

    This is a piece of code from one of our displaytag tables using a checkbox. This works for us.

    Here is an excerpt of the JSP code
    <display:table scope="request" name="specialCustomerForm.customerList" id="customerNo">
    <display:column headerClass="tabel_header" title="" ><input class="input_check" type="checkbox" name="customerNo" value='<bean:write name="customerNo" property="customerNumber"/>'></display:column>
    <display:column headerClass="tabel_header" title="&nbsp;Customer No" property="customerNumber" />
    </display:table>

    hope this helps
  5. Checkbox with displaytag[ Go to top ]

    Hi,

    Re: displaytag checkboxes, struts, & action class

    I have a question regarding the post below.... My question is once I checked on any of the checkboxes in the displaytag how can i pass it to my Action class (via struts). Thanks!

    From previous posts...

    This is a piece of code from one of our displaytag tables using a checkbox. This works for us.

    Here is an excerpt of the JSP code
    <display:table scope="request" name="specialCustomerForm.customerList" id="customerNo">
    <display:column headerClass="tabel_header" title="" ><input class="input_check" type="checkbox" name="customerNo" value='<bean:write name="customerNo" property="customerNumber"/>'></display:column>
    <display:column headerClass="tabel_header" title="&nbsp;Customer No" property="customerNumber" />
    </display:table>

    hope this helps
  6. delete temp files[ Go to top ]

    Hi, i got this same problem with a checkbox too.

    However, i made some changes and redployed and nothing happened.

    I had to stop the server, delete the work/temp files and restart - and after this, it worked.

    Thanks
    Dave