Tom Pierce's Blog : Let the geek times roll.
Updated: 6/20/04; 3:21:34 PM.

 

Subscribe to "Tom Pierce's Blog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Monday, January 19, 2004

I just spent too long debugging a little problem I was having with the Struts nested tags.  With the nested tags, you can define a "root" bean and then access properties off the root with special nested versions of the other Struts tags.  This allows you to access properties of beans with syntax like:

<nested:root name="customer">
Name = <nested:write property="name" />
</nested:root>


Which is really cool, especially with some of the more complex tags because you don't have to refer to the parent bean.  In theory, this allows you to also nest references to beans contained within the bean with something like:

<nested:root name="customer">
Name = <nested:write property="name" />

<nested:root name="address">
Address Line 1 = <nested:write property="line1" />
Address Line 2 = <nested:write property="line2" />
City = <nested:write property="city" />
</nested:root>

</nested:root>


However, the more you nest the tags within each other, the more flaky things are likely to get.  In my recent debugging session, I made the decision that from now on, nested roots should contain at most 1 nested root within them.  If you have more than 1 root defined within a root, all the subsequent tags outside the 1st nested root don't work correctly. 

As an example, I don't think you should do this:

<nested:root name="customer">
Name = <nested:write property="name" />

<nested:root name="address">
Address Line 1 = <nested:write property="line1" />
Address Line 2 = <nested:write property="line2" />
City = <nested:write property="city" />
</nested:root>

<nested:present name="altContact">
<nested:root name="altContact">
Name = <nested:write property="name"/>
</nested:root>
</nested:present>

</nested:root>


Because chances are that the tag logic won't determine that altContact is present correctly.

4:37:26 PM    comment []

Because I don't get to do it often enough, I always forget how to get the user id from the servlet container.  This is handy if you are letting the container handle the authentication for your application.  All you have to do is call request.getUserPrincipal().getName().  This returns the id as a String.  Beautiful.


3:07:57 PM    comment []

© Copyright 2004 Tom Pierce.



Click here to visit the Radio UserLand website.

 


January 2004
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Dec   Feb

Search

[sgl dagger]
How this works

Emacs Sources
 tsql-indent.el
 user-add-sql-folding-marks
 remove-line-boundary-in-region
 convert-camel-to-underscore

My Subscriptions
 Funny
 KM