Issue Details (XML | Word | Printable)

Key: DISPL-172
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Critical Critical
Reporter: Olaru Cristian
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DisplayTag

Internationalization for TableDecorator

Created: 12/Jan/05 03:15 AM   Updated: 26/Oct/05 03:58 PM   Resolved: 26/Oct/05 03:58 PM
Return to search
Component/s: I18N
Affects Version/s: 1.1
Fix Version/s: None

Time Tracking:
Original Estimate: 3 days
Original Estimate - 3 days
Remaining Estimate: 3 days
Remaining Estimate - 3 days
Time Spent: Not Specified
Time Spent - Not Specified


 Description  « Hide
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!!!

Gareth Davis added a comment - 12/Jan/05 03:28 AM
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

Olaru Cristian added a comment - 12/Jan/05 06:33 AM
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???

Gareth Davis added a comment - 12/Jan/05 08:15 AM
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

Gareth Davis added a comment - 13/Jan/05 10:26 AM
I haven't heard anything from Olaru on this so I guess somebody needs to close this issue for him.

Gareth

Ralf Hauser added a comment - 21/Apr/05 03:18 AM
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

fabrizio giustina added a comment - 26/Oct/05 03:58 PM
pageContext is already available in tableDecorators, as explained in comments, closing