• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts dyna objects

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using dynaforms, i have a customer form where i have one property as arraylist in dynaform

form-property name="activeInd" type="java.lang.String"
form-property name="assoc" type="java.util.ArrayList"

I am using display tags in the view everything works fine, but i have an add button in page where i can add a association, in one of java class i am updating the property like this when association is added by submitting request from add button

ArrayList currentAssocs = (ArrayList)customerForm.get("assoc");
String newAssocNumber = (String)customerForm.get("newAssocNumber");
Cust newAssocCust = Cust.readCustInfoFromDB(newAssocNumber, dataSession, transaction);
currentAssocs.add(newAssocCust);
customerForm.set("assoc",currentAssocs);

updating the form object with latest property with above code .later when i am trying to save(submit request from save button) I am trying to retrieve the arraylist i set but i dont get that back !!!
ArrayList currentAssocs = (ArrayList)customerForm.get("assoc");
if(currentAssocs!=null && currentAssocs.size()>0 ){
customer.setAssociations(currentAssocs);
}
//save customer code here..

in struts config i have set the scope as request

<action name="newcustomerForm" path="/Permits/NewCustomer" input="permits.NewCustomer" parameter="action" scope="request" type="us.ny.state.dot.permits.actions.CustomerDispatchAction" validate="false">
<set-property property="secure" value="true"/>
<forward name="successGet" path="permits.NewCustomer"/>
<forward name="successUpdate" path="permits.NewCustomer"/> <forward name="successPost" path="permits.CustomerCreated"/>
<forward name="replay" path="permits.NewCustomer"/>
</action>

any Ideas!
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you create a property in your form bean of type ArrayList, you can read from it, but you cannot write to it from a form submission. The Apache Commons BeanUtils used by Struts to convert request data to form bean properties cannot handle this conversion.

If you're not really intending to write to the ArrayList, just take it out of the form altogether and store it in request or session scope. Then you can read from it as needed, but it won't get wiped out when the form is submitted.
[ July 10, 2007: Message edited by: Merrill Higginson ]
 
Sri Anand
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for the reply, I got it working.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic