Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

submit a LIST in struts

Posted on 2007-04-02
6
1,275 Views
Last Modified: 2008-02-01
Hello Experts,

I'm programming JSP with Apache Struts and I haven't been able to find the way to submit a List property of the form to the next JSP

My case is the following:

I have a JSP (agentInteractions.jsp) where data is modified, this jsp is popoulated with a List property with the following code:

  <c:forEach items="${immunizationScheduleForm.agentInteractionsList}" var="agentList">
    <tr>
    <td align="center" class="lightgray">
       <html:radio name="agentList" property="interactionAgentKey" value="true"/>
    </td>
    <td align="left" class="lightgray">
      <html:select name="agentList" property="ruleCode">      
        <html:option value="1"><bean:write name="agentList" property="ruleDesc"/></html:option>      
     </html:select>
    </td>
    <td align="left" class="lightgray">
       <html:select name="agentList" property="ruleCode">
          <html:option value="1"><bean:write ame="agentList"property="interactionAgentDesc"/></html:option>
      </html:select>      
    </td>
    <td align="left" class="lightgray">
        <html:select name="agentList" property="interval">
           <html:option value="1"><bean:write name="agentList" property="interval"/></html:option>
        </html:select>&nbsp;      
        <html:select name="agentList" property="intervalUnits">
             <html:option value="1"><bean:write name="agentList" property="intervalUnitsDesc"/></html:option>
        </html:select>      
      </td>
    </tr>
  </c:forEach>

this jsp will go to the corresponding action, but when I get there, data from {immunizationScheduleForm.agentInteractionsList is NULL

I already tried to submit this property thru a hidden field (<html:hidden name="immunizationScheduleForm" property="agentInteractionsList " ?> but I get an error

I believe probably there's an special way to submit list property's

Thanks for your help. Urgent
0
Comment
Question by:mnateras
  • 2
  • 2
6 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 18840844
Could you pass your entire JSP with the corresponding ActionForm here?

Additionally, you are naming all the select boxes with the same name i.e. agentList.

        <html:select name="agentList" property="interval">
           <html:option value="1"><bean:write name="agentList" property="interval"/></html:option>
        </html:select>&nbsp;      
        <html:select name="agentList" property="intervalUnits">
             <html:option value="1"><bean:write name="agentList" property="intervalUnitsDesc"/></html:option>
        </html:select>    

David
0
 

Author Comment

by:mnateras
ID: 18845625
Thanks, I have found out a way to do it
for Each field in the List, I mapped a corresponding String[] property in the FormBean

ex:
List listVar;
   imagine list with 2 fields: field1, field2

we add the following propertys in the FormBean (ActionForm)
  String[] listField1
  String[] listField2

on the .jsp I mapped the fields
  <c:forEach items="${formBean.listVar}" var="listName">
    <html:select name="FormBean" property="listField1">
    ......
    <html:select name="FormBean" property="listField2">
    .......

And I get those arrarys populated with all the <select> values in the Action Class

Regards,
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18847958
Glad that you solved it by your own.

Shall I ask the page editor to remove this question and refund the points back to you?

David
0
 

Author Comment

by:mnateras
ID: 18848008
I have antoher issue regarding this same matter.
I have succesfully send all the values selected to the corresponding action.
Now I've been strugling populating the <html:select> with the corresponding values retrieved.
The situation is as follows:
I have all the values set in the corresponding arrays, which are
* scheduleAgentKey
* interactionAgentKey

My jsp is as follows
  <c:forEach items="${immunizationScheduleForm.agentInteractionsList}" var="agentList">
      <tr>
    <td align="left" class="lightgray">      
       <c:out value='${agentList.scheduleAgentKey}' />      
       <html:select name="immunizationScheduleForm" property="scheduleAgentKey" value="">      
                  <html:option value="1">scheduleAgent 1</html:option>
                  <html:option value="2">scheduleAgent 2</html:option      
            </html:select>
      </td>
    <td align="left" class="lightgray">
            <html:select name="immunizationScheduleForm" property="ruleCode">      
                  <html:option value="1">ruleCode 1</html:option>      
                  <html:option value="2">ruleCode 2</html:option>      
            </html:select>
      </td>
</c:forEach

I have found out that if i'm able to put the value I want to be selected in the <html:select value="valueToBeSelected"> it will work, but know the problem is:

HOW do I escape the value of agentList.scheduleAgentKey to this value property?

I already tried this
<html:select name="immunizationScheduleForm" property="scheduleAgentKey" value="${agentList.scheduleAgentKey} ">

And values were no selected properly (it just select the default value)

I already <c:out value="${agentList.scheduleAgentKey} "/> and the value is printed, but some how is not escaped in the select tag

Please help!!!
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19485752
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with Pie chart in Jsp 20 222
unit test DAO layer 1 139
getting Http 404 error in jsp forms 8 81
'exit' is not valid keyword in java 14 160
If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question