• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Nesting ognl expressions?

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Hold that thought. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic