PDA

View Full Version : More than one commandclass for a jsp file


anieshuk
Aug 25th, 2005, 03:50 AM
Hai users

Can me assign multiple commandClass to one jsp file (i,e) like a master detail structure.Master having one commandclass and detail another class

Thanks
anieshuk

sethladd
Aug 28th, 2005, 04:35 PM
The best way to do this is to create one command class that contains the other command classes. Simply nest your various command classes inside some Master Command class. The DataBinder has excellent support for nested classes.

anieshuk
Aug 29th, 2005, 12:37 AM
Hai
thanks for ur suggestion.But the value of the text box is not setting in the details bean.Look at ths in the master bean i am having


public void setDetail(Detail detail)
{
this.detail=detail;
}

In the jsp i am having

<input type="text'' name="variablename" path="master.detail.variablename/>



But the value from the text box is not setting properly.Shouls i change any other things.

Thanks
anieshuk

sethladd
Aug 29th, 2005, 02:09 PM
Make sure you are setting the commandName to 'master'. It might help to post your bean definition XML and your controller code.

sethladd
Aug 29th, 2005, 02:10 PM
Oh, and of course, you need to use the <spring:bind> tag, but I'm assuming you just accidently left it out of your example.

anieshuk
Aug 29th, 2005, 11:54 PM
Hai

There is no need for springbind tag as i am using this alternative method
"path =commandName.memeber".

Hope i am clear.

Thanks
aniesh UK

cujigar1
Aug 30th, 2005, 03:31 AM
The best way to do this is to create one command class that contains the other command classes. Simply nest your various command classes inside some Master Command class. The DataBinder has excellent support for nested classes.

can u point me some example/sample code so i can figure how "The DataBinder has excellent support for nested classes" ?

anieshuk
Aug 30th, 2005, 08:18 AM
Hai
Thanks i got the idea.To class the detail class in the master class right.I got.Then let me give the code
(Note pls make the above code as idea not the orginal one)


class Master{
name,no}
with setter methods
class Detail{
no,detailremarks

with setter and getter methods.
in the spring bind i shouls use like this

<spring:bing path="master.detail.detailremarks">
</spring:bind>


I am rigthThanks