• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to use 2 fmt tags? fmt:message in fmt:formatDate

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to use i18n. I need to use different date patterns, according of using language. String of date pattern I also keep in bundle with i18n messages. So I need to <fmt:formatDate/> with with value of pattern getting from i18n bundle. I need something like that, but my example doesn't work:

variable is a date and date.pattern is a pattern string for current language.
I tried different variants, like or
It both doesn't work. Please, help me!

P.s. I need to use pattern exactly, not dateStyle!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For any custom tags, you cannot use a custom tag as the attribute value of another custom tag.

Look carefully at the tag definitions in the JSTL spec and check if there are alternate ways to use the tags that would suit your situation.
 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that I can't use a custom tag as the attribute value of another custom tag, but I can't find any way to resolve my problem.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you inspect the tags? Hint: if you can't use a tag as an attribute value, what about using an EL expression? How could these tags be used in such a way?
 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I exactly understand you mean to set <fmt:message key="date.pattern"/> to some variable and then use this variable. I trid so but I can't find a way how to set <fmt:message key="date.pattern"/> to some variable.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read the documentation for the tag?
 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In all that I read I don't find any idea. May you can help me how to realize it.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You read through all the possible attributes of the tag, and you still don't see how the formatted value can be set into a scoped variable?

Description of the var attribute:

Name of the exported scoped variable which stores the localized message.

 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I saw this attribute, but I can't understand how to set it. If I right understand it will look like:

It doesn't work. What will be changed?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you are on the right track, But please read: ItDoesntWorkIsUseless. What is it doing?

Also, why are you mixing scriptlets with the JSTL and EL? That's a big (huge) red flag right there.

And, why session scope?
 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Session and scriptlet is just an example. It doesn't change the main problem how to do this code work.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, that's not the case. If you're not showing the real code, you are wasting time.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic