Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the documentation for the tag?
 
Sergey Deplake
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, that's not the case. If you're not showing the real code, you are wasting time.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!