Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nested tags

Status
Not open for further replies.

ajaybrar

Programmer
Oct 2, 2003
9
AU
hi!

i'm doing nested statements for the first time so please tell me where i am wrong.

can i write
<bean:write name=&quot;newUser&quot; property=&quot;name&quot;/>
as
<nested:root name=&quot;newUser&quot;>
<nested:write property=&quot;name&quot;/>
</nested:root>

would they give the same output? i'd think yes but my results dont seem to agree.

thanks
ajay
 
Hi,

It is just like using jsp:useBean tag in jsp. The above 2 lines of code gives a different result. You need to define the id in the <nested:root/> and the name attribute into write.

can i write
<bean:write name=&quot;newUser&quot; property=&quot;name&quot;/>
as
<nested:root id=&quot;user&quot; name=&quot;newUser&quot;>
<nested:write name=&quot;user&quot; property=&quot;name&quot;/>
</nested:root>

Cheers,
Venu
 
hi!
just a clarification,
useBean is used to bring the bean into scope, in my example above the bean is already placed in the session.

with nested tags, i thought the point was the the outer tag defines the bean (with eg: nested:root), then the inner
tags refer to that bean by default.
eg:
with what i had
<nested:root name=&quot;newUser&quot;>
<nested:write property=&quot;name&quot;/>
</nested:root>

wouldn't that be taken as name being a property defined in the bean newUser which has been introduced with the nested:root statement. otherwise what would be the motivation for using a nested statement.

with what you gave as an answer it, nested root it seems is being used only to provide an id for the bean tag (like you said with the useBean tag). why then would you use it, if you already had a bean placed in session scope.

Also the api for the nested tag, nested:root does not include an id attribute. so HOW would that work?

a tutorial i went through for recursing through tree structures and then displaying them used something like,
<nested:root name=&quot;newUser&quot;>
<nested:nest property=&quot;functions&quot; >
<jsp:include page=&quot;treenode.jsp&quot; />
</nested:nest>
</nested:root>

treenode.jsp goes as
<nested:root>
<nested:write property=&quot;nodeName&quot;/>
<nested:iterate property=&quot;children&quot;>
<jsp:include page=&quot;treenode.jsp&quot;/>
</nested:iterate>
</nested:root>
where newUser has a property functions, functions in turn has a property nodeName and children. and children again have the same structure in them (a tree)


 
hi!

found my error.
<nested:root name=&quot;newUser&quot;>
<nested:write property=&quot;name&quot;/>
</nested:root>

the above was fine and the reason i spend so many agonizing days looking for the error was because i didn't add the include statement for the tag, 'nested' at the start of my page and so it wasn't resolving the nested tags.

thanks for the help though
Ajay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top