• 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 2 is converting in XWorkList

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Struts 2 is converting to XWorkList instead of ArrayList when I send a select form. Help me please.

This is the debug image:



Link da imagem


Thanks.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.
According to the XWork documentation, XWorkList extends ArrayList, so your instance technically is an ArrayList. What exactly is the problem you have?
 
Bruno Porto
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply =D

I worked in a project that used struts 2 version 2.1.3 this aplication converted the sending the form directly to arraylist type defined in the field of action class, for example;

List<String> listOne = new ArrayList<String>();

public List<BigDecimal> getListOne() {
return listOne;
}

public void setListOne(List<String> listOne) {
this.listOne = listOne;
}

When struts 2 converted the request form, debugging the set method, the parameter listOne was at Arraylist<String> instead of XWorkList, but I cannot reply this effect to my application.

Thanks.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It's unnecessary to initialize listOne as Struts is going to invoke the setter.

Bruno Porto wrote:
When struts 2 converted the request form, debugging the set method, the parameter listOne was at Arraylist<String> instead of XWorkList, but I cannot reply this effect to my application.



I'm not sure what you mean here. The values you expected were in a list in the Struts code but Struts did not set that list in your action?
I will say that reflection requires that the method arguments in getters and setters agree and you have two different types in your getter and setter. Fix that and see if it changes anything.
 
Bruno Porto
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, the correct code is:


List<String> listOne = new ArrayList<String>();

public List<String> getListOne() {
return listOne;
}

public void setListOne(List<String> listOne) {
this.listOne = listOne;
}

Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic