• 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

displaying data from a single request object in struts2

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Following are the bean class,jsp class and action class used in struts2.
Problem is:-I am displaying data through a request object in jsp class
<s roperty id="detail" value="#request['custinfo']" />
Through this tag,but it is fetching all the data in request object and displaying.

I have many fields such as
customerBasicInfoVo.setPersBusinessInd("P");
customerBasicInfoVo.setNameLine1("PHILLIP W ROBINSON");
and so on��I want all PersBusinessInd to be displayed in different <td> in jsp and NameLine1 to be in different <td>.
I am not able to do that because everything is in single request object.


Is there any way to iterate the values I am entering in the string buffer�I used list also but again the problem is same all data is being displayed in single <td> only


Bean Class
-------------

public class CustomerDetailedInfoVo {

private CustomerBasicInfoVo customerBasicInfoVo;
private ClientSearchByOlbIdVo clientSearchByOlbIdVo;

public CustomerBasicInfoVo getCustomerBasicInfoVo() {
return customerBasicInfoVo;
}

public void setCustomerBasicInfoVo(CustomerBasicInfoVo customerBasicInfoVo) {
this.customerBasicInfoVo = customerBasicInfoVo;
}

public ClientSearchByOlbIdVo getClientSearchByOlbIdVo() {
return clientSearchByOlbIdVo;
}

public void setClientSearchByOlbIdVo(ClientSearchByOlbIdVo clientSearchByOlbIdVo) {
this.clientSearchByOlbIdVo = clientSearchByOlbIdVo;
}

public String toString(){
StringBuffer str=new StringBuffer();

str.append(this.customerBasicInfoVo.getPersBusinessInd());

str.append(this.customerBasicInfoVo.getNameLine1());

return str.toString();
}

}

JSP Page
------------

<table BORDER="1" CELLPADDING="3" CELLSPACING="1">

<tr>
<td>PersBusinessInd: </td>
<td>
<s roperty id="detail" value="#request['custinfo']" />

</td></tr>
<tr>
<td>NameLine1:</td>
<td>




</td></tr>
</table>

Action Class
--------------

public String execute() throws Exception {
CustomerDetailedInfoVo customerDetailedInfoVo=new CustomerDetailedInfoVo();
CustomerBasicInfoVo customerBasicInfoVo=new CustomerBasicInfoVo();
customerBasicInfoVo.setPersBusinessInd("M");
customerBasicInfoVo.setNameLine1("ANI");

customerDetailedInfoVo.setCustomerBasicInfoVo(customerBasicInfoVo);
getServletRequest().setAttribute("custinfo", customerDetailedInfoVo);
return SUCCESS;
}
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use UBB code to format your code (and disable smilies).

Your property tag is <s:property value="#request['custinfo']"/>, so it'll display the entire object. Use OGNL to get a specific property of the 'custinfo' object: #request['custinfo'].firstName or whatever.

That said, this is non-canonical Struts 2. Normally objects to be displayed in the JSP would be an action property with a public getter, so in the JSP you could use either of the following:



Dave
[ November 17, 2008: Message edited by: David Newton ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic