aspose file tools*
The moose likes Struts and the fly likes displaying data from a single request object in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "displaying data from a single request object in struts2" Watch "displaying data from a single request object in struts2" New topic
Author

displaying data from a single request object in struts2

aihadus tisidns
Greenhorn

Joined: Nov 14, 2008
Posts: 9
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;
}
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: displaying data from a single request object in struts2