aspose file tools*
The moose likes Struts and the fly likes Nesting ognl expressions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Nesting ognl expressions?" Watch "Nesting ognl expressions?" New topic
Author

Nesting ognl expressions?

Nathan Russell
Ranch Hand

Joined: Aug 18, 2004
Posts: 75
I wonder if anyone can help.
I'm trying to create a new struts2 tag to render and operate as a 3 field date control. IE. a single jsp tag which results in 3 html input controls nicely laid out. Ignoring the complications of individual field validations (eg: month field is Feb, day field cant be > 28 unless year field is a leap year in which case it can be 29!). Anyway, ignoring that ..... I'm struggling with populating the value attribute.

I have a class which I'll use to store dates - its basically a wrapper around java.util.Date (I might use GregorianCalandar instead) which has getters and setters for day, month and year. In my action class I have a member variable whose type is my Date class, and I have a getter and setter for the field dob which gets and sets this member variable:

I reference my tag like this:

And my ftl looks like this:

The bit I'm having a problem with is the value attribute of each of the fields (where in the code above I've written it as value="problem area!")
What I think I want to do is in the jsp pass an ognl reference to the action class's member variable:

This I guess calls the action class's getDob method which will return the Date object. So then within the ftl I would want to do something like this:


But I cant get this (or similar syntax) to work.
As usual, any pointers very much appreciated !

Cheers

Nathan

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Seems more a FreeMarker issue. ${parameters.value.day} doesn't work?

In any case, I'd check existing FreeMarker tags to see if anything has similar functionality.
Nathan Russell
Ranch Hand

Joined: Aug 18, 2004
Posts: 75
Thanks for your reply David, but no, ${parameters.value.day} does not work - I get the following stack trace:

but if I simply use ${parameters.value} it returns mypackage.Date@805af4

So, as I see it, my object is being stored in the parameters map under the key 'value', and it is being returned correctly. Its just that for some reason I cant work out how to invoke the getDay() method?

Back to google I think !

Cheers

Nathan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nesting ognl expressions?