In Struts1.3, From Jsp page to action in Java
Asked Answered
C

1

0

I am new to Jsp, and My working application is based on Struts1.3. I have a Jsp page which display the records basis on the providedId, may be record should be one or more than one it depends on the existence of records. My Jsp page code is:

<html:form method="post" action="properties.do" styleId="propertyform">
  <logic:iterate id="JobsForm" name="<%=Constant.JOBFORMLISTSECOND%>">
    <tr>
      <td>
        <html:text property="asfrom" name="JobsForm" styleClass="fieldbox2" styleId="textfield50"/>
      </td>

      <td>
        <html:select property="withauthority" name="JobsForm">
          <html:option value="0">Select</html:option>
          <html:options collection="<%=Constant.INSTALLEDBY%>" property="value" labelProperty="label"/>
        </html:select>
      </td>
    </tr>
  </logic:iterate>

  <table>
    <tr>
      <td>
        <img onclick="submitPropertyForm(),update()" src="images/new.jpg" />
      </td>
    </tr>
  </table>
</html:form>

And, What i need, after clicking on the button I need all the values of given properties but I am unable to do this, I got only one value of all properties in my action my action is like.

JobsForm jobsForm = (JobsForm) form;
System.out.println("asFrom:::" + jobsForm.getAsfrom());
System.out.println("withAuth:::" + jobsForm.getWithauthority());  

Can you guide me how to do this.Or What i have to do? for getting all the values of all properties.

Many Thanks,

Christie answered 28/10, 2011 at 10:20 Comment(0)
V
0

You want indexed properties.

Basically, you need to provide names like asfrom[n] where n is your loop index.

Struts does provide indexed tags, although the documentation lists some reasons you might just want to use JSTL. That just depends on your needs.

On a side note, please take care when formatting your code, both for your benefit, and that of others. Proper indentation and whitespace usage make structure and intent far easier to communicate, and it's one way to tell if someone cares about their code. I also removed some JSP not necessary to describe the problem.

Verdin answered 28/10, 2011 at 14:37 Comment(1)
Thanks @Dave Newton: Can you give me any example which is based on my query. I am unable to do this that's i am posting one more question like almost same. that is on this link #7971517Christie

© 2022 - 2024 — McMap. All rights reserved.