Hi everyone, I have a object that have others object like objA has objB that has objC an go on. I�ve tried to use html tag but it didn�t work. Let�s suppose i want the id of objD, so i did . How could i do that?
The code you've shown us could work provided your ActoinForm is structured and populated properly. Please tell us what "didn't work" means. What error messages did you get? What happened that you didn't expect to happen? Is there a getter and setter for objA on your ActionForm? Is there a getter and setter for objB in objA, etc?
If your Action form is in request scope, you will need to do a little more work with your ActionForm to give it "lazy initialization" behavior. This link provides more details on how to do that. [ September 06, 2006: Message edited by: Merrill Higginson ]
hmmm...the way that the html tags work is that if you do not give a name attribute, it defaults to the form of the enclosing html:form tag. Maybe you need to change your tag to use:
name="objA" property=" objB.objC.objD.id"
Joined: Feb 15, 2005
The <html:text> tag operates on the ActionForm bean. That means that any nested objects must be accessible through the ActionForm. Whether ObjA is in the session or not is completely irrelevant. So, in order for this tag to work:
Your ActionForm bean must have a getObjA() method, OjbA must have a getObjB() method, etc.
Joined: Jul 11, 2005
Hello, I�m sorry, by objA i mean my ActionForm. That ActionForm has gets and sets for objB, that has gets and sets for objC etc. I just don�t undestand why if i put <html:text property="objB.id"> works and <html:text property="objB.objC.objD.id"> don�t.
Joined: Feb 15, 2005
What I'm telling you is that the reason this isn't working for you must be that your beans are not coded properly. Struts does allow for nested properties, and you can go as many levels deep as you want. I'd check each of your getter methods on your objects to see if there is a misspelling somewhere. I'd also check to see that ObjA really does contain a non-null reference to ObjB, and that ObjB contains a reference to ObjC, etc.
I frequently use nested properties going three or four levels deep, so I know this works.