Thanks Laurie,

I tried to set it up this way, but wasn't able to make it work. My
struts-config file defines the message-resources parameter like so:

        <message-resources parameter="ApplicationResources"
null="false"/>

So I tried putting that in, and also tried some variants like
org.apache.struts.ApplicationResources and
org.apache.struts.util.MessageResources in code like this:

        <tiles:useAttribute id="directionToUserKey"
name="directionToUserKey" scope="request" classname="java.lang.String"
ignore="true"/>
        
        <logic:present name="ApplicationResources"
property="<%=directionToUserKey.toString()%>">
                <div class="modFormBox"><bean:message
key="<%=directionToUserKey.toString()%>"/></div>
        </logic:present> 

But it always returned false, even if there was a value for the key, so
I apparently set up something wrong.

I did get it working using the alternate path, however -- I set up a new
tile in the tiles-defs file which was defined as a zero-length file in
the default case and a small JSP for those cases where I had directions.
The calling JSP looks like this:

        <tiles:useAttribute id="directionToUserKey"
name="directionToUserKey" scope="request" classname="java.lang.String"
ignore="true"/>
        
        <!-- Next is the inserted tile -->
        <tiles:insert attribute="directionToUserTile"/>

And the inserted tile (when I insert a non-zero-length file) looks like
this:

<%
        String directionsKey = (String)
request.getAttribute("directionToUserKey");
%>

<div class="modFormBox"><bean:message key="<%=directionsKey%>"/></div>

That is working ok, though of course I don't have the flexibility of
having a value for some locales and no value for other locales. That's
not terribly important.

By the way, just for my own learning: I initially tried to put the
attribute in page scope, but I kept getting a null value: is page scope
specific to a particular JSP (I would have thought that was tile
scope...), or should it be available throughout the sub-elements of a
given page? It works when I use request scope instead, but is that what
is required here?

Thanks again for everyone's help!

Chris Loschen

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
Sent: Thursday, June 09, 2005 7:07 PM
To: user@struts.apache.org
Subject: Re: Test whether an application resource is empty

Try:

   <tiles:useAttribute name="directionToUser" ...
   <logic:present name="org.apache.struts...
                  property="<%=directionToUser.toString()%>">
     <div class="modFormBox">...</div>
   </logic:present>

where 'name' is the name of the attribute your resource bundle is stored
under.

L.

Chris Loschen wrote:

> Hi Wendy,
> 
> Thank you very much for your reply.
> 
> Yes, I also thought that I could test the key, then check to see if 
> the value was empty. But just how to do it is eluding me. I think part

> of the problem might be this:
> 
> USAGE NOTE - If you use another tag to create the body content (e.g.
> bean:write), that tag must return a non-empty String. An empty String 
> equates to an empty body or a null String, and a new scripting 
> variable cannot be defined as null. Your bean must return a non-empty 
> String, or the define tag must be wrapped within a logic tag to test 
> for an empty or null value.
> 
> (from the Struts User Guide for bean:define at 
> http://struts.apache.org/userGuide/struts-bean.html#define).
> 
> I'm trying to do something like
> 
>       <tiles:useAttribute name="directionToUser"
> classname="java.lang.String"/>
>       
>       <bean:define id="directionToUserString"
> class="java.lang.String">
>               <bean:message key="<%=directionToUser.toString()%>"/>
>       </bean:define>
> 
>       <logic:notEmpty name="directionToUserString">
>               <div class="modFormBox"><bean:write
> name="directionToUserString"/></div>
>       </logic:notEmpty>
> 
> But it's failing (I think) because the bean:message returns an empty 
> String. I would wrap it in a logic tag as suggested, but if I could do

> that, I'd just use the same logic for my logic:notEmpty tag instead. 
> So finding a way to take that value and assign that to a variable 
> which I can then test to see whether or not it's empty is what I'm
trying to do.
> 
> It was not my idea to add all of these empty i18n values: the i18n 
> team did it. If I can't find a way to make this idea work, that's my 
> alternate path. If that's the road I need to take, I can do it -- I 
> was just hopeful I could do this a little more elegantly.
> 
> Thanks for your input. Any further ideas?
> 
> Chris
> 
> -----Original Message-----
> From: Wendy Smoak [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 09, 2005 11:52 AM
> To: Struts Users Mailing List
> Subject: Re: Test whether an application resource is empty
> 
> From: "Chris Loschen" <[EMAIL PROTECTED]>
> 
>>Quick synopsis: I have localized i18n messages defined in my tiles 
>>definitions which are sometimes empty. I need to test that the value 
>>associated with a given key is not empty before I proceed with further
> 
> 
>>processing. I can test that the key is non-empty, but I haven't yet 
>>figured out how to test the same thing for the value.
> 
> 
> If you can test the key, then it would seem that removing the empty 
> messages would solve the problem.  Why are the empty ones there in the

> first place?
> Can you get rid of them?
> 
> --
> Wendy Smoak
> 


_______________
Siebel
IT'S ALL ABOUT THE CUSTOMER
Visit www.siebel.com

This e-mail message is for the sole use of the intended recipient(s) and 
contains confidential and/or privileged information belonging to Siebel 
Systems, Inc. or its customers or partners. Any unauthorized review, use, 
copying, disclosure or distribution of this message is strictly prohibited. If 
you are not an intended recipient of this message, please contact the sender by 
reply e-mail and destroy all soft and hard copies of the message and any 
attachments. Thank you for your cooperation.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to