You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Styles <gi...@hotmail.com> on 2004/01/07 20:48:42 UTC

Handling Missing Message Key

Hi all,

I'm using the i8ln features in the struts bean tag library

I populate a form bean with info from the database, and this info acts as 
the key in a resource bundle so that I can add a international versions 
using

<bean:message name="form" property="database_property"/>

however, I would very much like the actual underlying property to be written 
out if the key doesn't exist in the resource bundle, rather than getting the 
nasty missing message key exception. Is this possible?

thanks very much,
Brian

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Handling Missing Message Key

Posted by Kris Schneider <kr...@dotech.com>.
Pretty sure you'd have to handle that yourself. It's probably cleaner to do it
in an action.

Action class:

String dbProp = ...;
MessageResources messages = getResources(request);
String message = dpProp;
if (messages.isPresent(dbProp)) {
  message = messages.getMessage(dbProp);
}
request.setAttribute("message", message);

JSP:

<bean:write name="message"/>

Or I suppose you could write your own tag...

Quoting Brian Styles <gi...@hotmail.com>:

> Hi all,
> 
> I'm using the i8ln features in the struts bean tag library
> 
> I populate a form bean with info from the database, and this info acts as 
> the key in a resource bundle so that I can add a international versions 
> using
> 
> <bean:message name="form" property="database_property"/>
> 
> however, I would very much like the actual underlying property to be written
> 
> out if the key doesn't exist in the resource bundle, rather than getting the
> 
> nasty missing message key exception. Is this possible?
> 
> thanks very much,
> Brian

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Handling Missing Message Key

Posted by Manfred Wolff <ma...@manfred-wolff.de>.
Yes: Set null to false in the <message-resources> tag:

    <message-resources parameter="resources.application" null="false"/>

Then you get something like this ???database_property??? by a missing key.

Manfred


Brian Styles wrote:

> Hi all,
>
> I'm using the i8ln features in the struts bean tag library
>
> I populate a form bean with info from the database, and this info acts 
> as the key in a resource bundle so that I can add a international 
> versions using
>
> <bean:message name="form" property="database_property"/>
>
> however, I would very much like the actual underlying property to be 
> written out if the key doesn't exist in the resource bundle, rather 
> than getting the nasty missing message key exception. Is this possible?
>
> thanks very much,
> Brian
>
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

-- 
===========================================
Dipl.-Inf. Manfred Wolff
-------------------------------------------
phone neusta  : +49 421 20696-27
phone         : +49 421 534522
mobil         : +49 178 49 18 434
eFax          : +49 1212 6 626 63 965 33
-------------------------------------------
____________________________________________________
Diese E-Mail enthält möglicherweise vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Handling Missing Message Key

Posted by Mike Jasnowski <mj...@bea.com>.
set the 'null' property in the config for the msg bundle to 'false' so the
exception doesn't happen, the DTD for the struts config details it more

-----Original Message-----
From: Brian Styles [mailto:givemeadamnusername@hotmail.com]
Sent: Wednesday, January 07, 2004 2:49 PM
To: struts-user@jakarta.apache.org
Subject: Handling Missing Message Key


Hi all,

I'm using the i8ln features in the struts bean tag library

I populate a form bean with info from the database, and this info acts as
the key in a resource bundle so that I can add a international versions
using

<bean:message name="form" property="database_property"/>

however, I would very much like the actual underlying property to be written
out if the key doesn't exist in the resource bundle, rather than getting the
nasty missing message key exception. Is this possible?

thanks very much,
Brian

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org