DisplayTag

Internationalization for TableDecorator

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.1
  • Fix Version/s: None
  • Component/s: I18N
  • Labels:
    None

Description

I extend TableDecorator for different sorting that what it is see in the column. The content of cells for this column must be internationalizated:

For examle a method:

public String getListaComenzi3()
{
VizualizareComenzi lObject= (VizualizareComenzi)getCurrentRowObject();
int lIndex= getListIndex();
String sar ="";
if(lObject.getStareFactura().equals("2"))
sar = "<a href='/Festino/vizualizeazaFactura.do?comanda_id=" + lObject.getId()+ "&client_id=" + lObject.getCliId() + "' > " +
"<img src='images/check.gif' alt='Visualizza fattura' border='0'>" +
" </a>";
return sar;
}

In this case the "alt" must be language dependent but I dont have acces to the current locale.


Do you see a method to have acces to Struts localization in TableDecorator.

Or another method for internationalize in this case (I need Struts localization , not request)???

Thanks!!!

Activity

Hide
Gareth Davis added a comment -
Hi,

in a TableDecorator you have access to the PageContext (getPageContext())

Struts leaves the current users Locale in the session under Globals.LOCALE_KEY (Globals is in package org.apache.struts). Some thing along the lines of:

Locale loc = (Locale)getPageContext().findAttribute(Globals.LOCALE_KEY) ;


Hope this helps.
Gareth
Show
Gareth Davis added a comment - Hi, in a TableDecorator you have access to the PageContext (getPageContext()) Struts leaves the current users Locale in the session under Globals.LOCALE_KEY (Globals is in package org.apache.struts). Some thing along the lines of: Locale loc = (Locale)getPageContext().findAttribute(Globals.LOCALE_KEY) ; Hope this helps. Gareth
Hide
Olaru Cristian added a comment -
Thanks a lot!!!

Now I optain the Locale, but I must find a way to optain a reference to my struts resource messages. Is a easy way to do this in TableDecorator???
Show
Olaru Cristian added a comment - Thanks a lot!!! Now I optain the Locale, but I must find a way to optain a reference to my struts resource messages. Is a easy way to do this in TableDecorator???
Hide
Gareth Davis added a comment -
there is some new stuff in display tag that I not very familar to do with pluging different i18n provides in to it.

The simplest solution for you (see that you're using struts anyway) is to use the TagUtils.message() method in org.apache.struts.taglib.

From MessageTag.doStart(){

        String message =
            TagUtils.getInstance().message(
                pageContext,
                this.bundle,
                this.localeKey,
                key,
                args);
}

or a even quicker/simplier way is to get the MessageResources is
getPageContent().findAttribute(Globals.MESSAGE_KEY);

Note this should give you the default messages, which may not be what you want (struts modules and all)

Gareth
Show
Gareth Davis added a comment - there is some new stuff in display tag that I not very familar to do with pluging different i18n provides in to it. The simplest solution for you (see that you're using struts anyway) is to use the TagUtils.message() method in org.apache.struts.taglib. From MessageTag.doStart(){         String message =             TagUtils.getInstance().message(                 pageContext,                 this.bundle,                 this.localeKey,                 key,                 args); } or a even quicker/simplier way is to get the MessageResources is getPageContent().findAttribute(Globals.MESSAGE_KEY); Note this should give you the default messages, which may not be what you want (struts modules and all) Gareth
Hide
Gareth Davis added a comment -
I haven't heard anything from Olaru on this so I guess somebody needs to close this issue for him.

Gareth
Show
Gareth Davis added a comment - I haven't heard anything from Olaru on this so I guess somebody needs to close this issue for him. Gareth
Hide
Ralf Hauser added a comment -
The same desire localization also exists for columns (DISPL-204), however, since there, the application-programmer-provided class does not extend an existing displaytag class, but only implement an interface, the solution is not going to be as easy as here
Show
Ralf Hauser added a comment - The same desire localization also exists for columns (DISPL-204), however, since there, the application-programmer-provided class does not extend an existing displaytag class, but only implement an interface, the solution is not going to be as easy as here
Hide
fabrizio giustina added a comment -
pageContext is already available in tableDecorators, as explained in comments, closing
Show
fabrizio giustina added a comment - pageContext is already available in tableDecorators, as explained in comments, closing

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
3d
Original Estimate - 3 days
Remaining:
3d
Remaining Estimate - 3 days
Logged:
Not Specified
Time Spent - Not Specified