Re: Test whether an application resource is empty
What you're missing is the next line of code which performs the test. The define just makes the resource bundle available. As long as you have at least one message resource bundle defined in struts-config.xml the line you quote won't fail. L. Nitish Kumar wrote: I dont understand some things here, If the application resource is empty above code would throw this error, "Define tag cannot set a null value". So how does this code helps in checking wether an application resouce is empty? Am I missing some thing here? or may be the subject is misleading.. Thanks and Regards, Nitish Kumar Tavant Technologies Ltd Bangalore -Original Message- From: Laurie Harper [mailto:[EMAIL PROTECTED] Sent: Sunday, June 12, 2005 6:30 AM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty Doh, I'm an idiot! :-( What I suggested is like trying to call getFoo() on the resource bundle bean, where 'Foo' is what ever <%=directionToUserKey.toString()%> evaluates to. Clearly not what's needed. The following works for me: using Struts bean/logic Just replace 'errors.cancel' with '<%=directionToUserKey.toString()%>' and you should be set. Sorry for the confusion, L. Chris Loschen wrote: Thanks again, Laurie, but for some reason it still returns false every time, even if there is something under that key. I'm pretty sure I followed your directions exactly: Although I did have to pull the key back out of the request in my second tile -- do I have to do that here as well? I may have to give up for now, since I have it working the other way, but I'm still curious what I did wrong. Chris -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Friday, June 10, 2005 2:49 PM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty You want to use the name of the attribute the resource bundle is stored under, not the name of the properties file. You're not specifying it in your Struts config so you want the following: ... L. Chris Loschen wrote: 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: 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: key="<%=directionToUserKey.toString()%>"/> 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: And the inserted tile (when I insert a non-zero-length file) looks like this: <% String directionsKey = (String) request.getAttribute("directionToUserKey"); %> 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: "> ... 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
Re: Test whether an application resource is empty
Chris Loschen wrote: As I understand it, this would return the error only if there are no messages at all in the application resource, which is not at all likely in this context. We're testing whether a particular application resource (that is, a particular key-value pair in the application resource file) is empty, not the whole file. No, it should return the error only if the resource named resource string exists. The key is the 'special' property name 'message(foo)', which translates into 'messages.getMessage("foo"). For me, if 'foo' is a valid message key I get the body of the tag displayed; if 'foo' is not defined in my resource bundle, I don't. That said, I still didn't get the results I had hoped for with the new version either, unfortunately. I didn't get any errors, but it returned true even when the value was empty. For example, when I had an application resource key set up like so: module.admin.manageHierarchy.businessStruc.add.directionToUser= Hmm, I hadn't tried that; I just tested it and it worked for me. And my JSP code is set up like this: It returns notEmpty as true, because I get this in the page: I presume it must be testing that the key exists and is non-zero-length rather than testing the value. Oh well. That's odd. Here's a copy/paste of my test, which works as expected: test 1 property="message(errors.cancel.missing)"> test 2 <% String foo = "errors.cancel.missing"; %> test 3 That gives me a single paragraph, 'test 1'. Works whether 'errors.cancel.missing' is actually missing, or defined with an empty value as in your example. If it doesn't work for you I'm out of ideas! :-/ L. Chris -----Original Message----- From: Nitish Kumar [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 12:54 AM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty I dont understand some things here, If the application resource is empty above code would throw this error, "Define tag cannot set a null value". So how does this code helps in checking wether an application resouce is empty? Am I missing some thing here? or may be the subject is misleading.. Thanks and Regards, Nitish Kumar Tavant Technologies Ltd Bangalore -Original Message- From: Laurie Harper [mailto:[EMAIL PROTECTED] Sent: Sunday, June 12, 2005 6:30 AM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty Doh, I'm an idiot! :-( What I suggested is like trying to call getFoo() on the resource bundle bean, where 'Foo' is what ever <%=directionToUserKey.toString()%> evaluates to. Clearly not what's needed. The following works for me: using Struts bean/logic Just replace 'errors.cancel' with '<%=directionToUserKey.toString()%>' and you should be set. Sorry for the confusion, L. Chris Loschen wrote: Thanks again, Laurie, but for some reason it still returns false every time, even if there is something under that key. I'm pretty sure I followed your directions exactly: key="<%=directionToUserKey.toString()%>"/> Although I did have to pull the key back out of the request in my second tile -- do I have to do that here as well? I may have to give up for now, since I have it working the other way, but I'm still curious what I did wrong. Chris -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Friday, June 10, 2005 2:49 PM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty You want to use the name of the attribute the resource bundle is stored under, not the name of the properties file. You're not specifying it in your Struts config so you want the following: ... L. Chris Loschen wrote: 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: 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: key="<%=directionToUserKey.toString()%>"/> 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 loo
RE: Test whether an application resource is empty
As I understand it, this would return the error only if there are no messages at all in the application resource, which is not at all likely in this context. We're testing whether a particular application resource (that is, a particular key-value pair in the application resource file) is empty, not the whole file. That said, I still didn't get the results I had hoped for with the new version either, unfortunately. I didn't get any errors, but it returned true even when the value was empty. For example, when I had an application resource key set up like so: module.admin.manageHierarchy.businessStruc.add.directionToUser= And my JSP code is set up like this: It returns notEmpty as true, because I get this in the page: I presume it must be testing that the key exists and is non-zero-length rather than testing the value. Oh well. Chris -Original Message- From: Nitish Kumar [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 12:54 AM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty I dont understand some things here, If the application resource is empty above code would throw this error, "Define tag cannot set a null value". So how does this code helps in checking wether an application resouce is empty? Am I missing some thing here? or may be the subject is misleading.. Thanks and Regards, Nitish Kumar Tavant Technologies Ltd Bangalore -Original Message- From: Laurie Harper [mailto:[EMAIL PROTECTED] Sent: Sunday, June 12, 2005 6:30 AM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty Doh, I'm an idiot! :-( What I suggested is like trying to call getFoo() on the resource bundle bean, where 'Foo' is what ever <%=directionToUserKey.toString()%> evaluates to. Clearly not what's needed. The following works for me: using Struts bean/logic Just replace 'errors.cancel' with '<%=directionToUserKey.toString()%>' and you should be set. Sorry for the confusion, L. Chris Loschen wrote: > Thanks again, Laurie, but for some reason it still returns false every > time, even if there is something under that key. I'm pretty sure I > followed your directions exactly: > >name="directionToUserKey" scope="request" classname="java.lang.String" > ignore="true"/> > >property="<%=directionToUserKey.toString()%>"> >key="<%=directionToUserKey.toString()%>"/> > > > Although I did have to pull the key back out of the request in my > second tile -- do I have to do that here as well? I may have to give > up for now, since I have it working the other way, but I'm still > curious what I did wrong. > > Chris > > -Original Message- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper > Sent: Friday, June 10, 2005 2:49 PM > To: user@struts.apache.org > Subject: Re: Test whether an application resource is empty > > You want to use the name of the attribute the resource bundle is > stored under, not the name of the properties file. You're not > specifying it in your Struts config so you want the following: > >property="<%=directionToUserKey.toString()%>"> > ... > > > L. > > Chris Loschen wrote: > >>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: >> >> >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: >> >> >name="directionToUserKey" scope="request" classname="java.lang.String" >>ignore="true"/> >> >> >property="<%=directionToUserKey.toString()%>"> >> >key="<%=directionToUserKey.toString()%>"/> >> >> >>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: >> >> >name="directionToUserKey" scope="request" classname="java.lang.String"
RE: Test whether an application resource is empty
I dont understand some things here, If the application resource is empty above code would throw this error, "Define tag cannot set a null value". So how does this code helps in checking wether an application resouce is empty? Am I missing some thing here? or may be the subject is misleading.. Thanks and Regards, Nitish Kumar Tavant Technologies Ltd Bangalore -Original Message- From: Laurie Harper [mailto:[EMAIL PROTECTED] Sent: Sunday, June 12, 2005 6:30 AM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty Doh, I'm an idiot! :-( What I suggested is like trying to call getFoo() on the resource bundle bean, where 'Foo' is what ever <%=directionToUserKey.toString()%> evaluates to. Clearly not what's needed. The following works for me: using Struts bean/logic Just replace 'errors.cancel' with '<%=directionToUserKey.toString()%>' and you should be set. Sorry for the confusion, L. Chris Loschen wrote: > Thanks again, Laurie, but for some reason it still returns false every > time, even if there is something under that key. I'm pretty sure I > followed your directions exactly: > >name="directionToUserKey" scope="request" classname="java.lang.String" > ignore="true"/> > >property="<%=directionToUserKey.toString()%>"> >key="<%=directionToUserKey.toString()%>"/> > > > Although I did have to pull the key back out of the request in my second > tile -- do I have to do that here as well? I may have to give up for > now, since I have it working the other way, but I'm still curious what I > did wrong. > > Chris > > -----Original Message- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper > Sent: Friday, June 10, 2005 2:49 PM > To: user@struts.apache.org > Subject: Re: Test whether an application resource is empty > > You want to use the name of the attribute the resource bundle is stored > under, not the name of the properties file. You're not specifying it in > your Struts config so you want the following: > >property="<%=directionToUserKey.toString()%>"> > ... > > > L. > > Chris Loschen wrote: > >>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: >> >> >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: >> >> >name="directionToUserKey" scope="request" classname="java.lang.String" >>ignore="true"/> >> >> >property="<%=directionToUserKey.toString()%>"> >> >key="<%=directionToUserKey.toString()%>"/> >> >> >>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: >> >> >name="directionToUserKey" scope="request" classname="java.lang.String" >>ignore="true"/> >> >> >> >> >>And the inserted tile (when I insert a non-zero-length file) looks >>like >>this: >> >><% >> String directionsKey = (String) >>request.getAttribute("directionToUserKey"); >>%> >> >> >> >>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 >> >&g
Re: Test whether an application resource is empty
Doh, I'm an idiot! :-( What I suggested is like trying to call getFoo() on the resource bundle bean, where 'Foo' is what ever <%=directionToUserKey.toString()%> evaluates to. Clearly not what's needed. The following works for me: using Struts bean/logic Just replace 'errors.cancel' with '<%=directionToUserKey.toString()%>' and you should be set. Sorry for the confusion, L. Chris Loschen wrote: Thanks again, Laurie, but for some reason it still returns false every time, even if there is something under that key. I'm pretty sure I followed your directions exactly: Although I did have to pull the key back out of the request in my second tile -- do I have to do that here as well? I may have to give up for now, since I have it working the other way, but I'm still curious what I did wrong. Chris -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Friday, June 10, 2005 2:49 PM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty You want to use the name of the attribute the resource bundle is stored under, not the name of the properties file. You're not specifying it in your Struts config so you want the following: ... L. Chris Loschen wrote: 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: 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: key="<%=directionToUserKey.toString()%>"/> 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: And the inserted tile (when I insert a non-zero-length file) looks like this: <% String directionsKey = (String) request.getAttribute("directionToUserKey"); %> 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: "> ... 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 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 Mess
RE: Test whether an application resource is empty
Thanks again, Laurie, but for some reason it still returns false every time, even if there is something under that key. I'm pretty sure I followed your directions exactly: Although I did have to pull the key back out of the request in my second tile -- do I have to do that here as well? I may have to give up for now, since I have it working the other way, but I'm still curious what I did wrong. Chris -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Friday, June 10, 2005 2:49 PM To: user@struts.apache.org Subject: Re: Test whether an application resource is empty You want to use the name of the attribute the resource bundle is stored under, not the name of the properties file. You're not specifying it in your Struts config so you want the following: ... L. Chris Loschen wrote: > 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: > >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: > >name="directionToUserKey" scope="request" classname="java.lang.String" > ignore="true"/> > >property="<%=directionToUserKey.toString()%>"> >key="<%=directionToUserKey.toString()%>"/> > > > 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: > >name="directionToUserKey" scope="request" classname="java.lang.String" > ignore="true"/> > > > > > And the inserted tile (when I insert a non-zero-length file) looks > like > this: > > <% > String directionsKey = (String) > request.getAttribute("directionToUserKey"); > %> > > > > 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: > >"> > ... > > > 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 >> >> >classname="java.lang.String"/> >> >> >class="java.lang.String"> >> >> >> >> >> >name="directionToUserString"/> >> >> >>But it's failing (I think) because the bean:message returns an empty >>String. I would wrap it in a logic tag
Re: Test whether an application resource is empty
You want to use the name of the attribute the resource bundle is stored under, not the name of the properties file. You're not specifying it in your Struts config so you want the following: ... L. Chris Loschen wrote: 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: 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: 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: And the inserted tile (when I insert a non-zero-length file) looks like this: <% String directionsKey = (String) request.getAttribute("directionToUserKey"); %> 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: "> ... 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 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 sen
RE: Test whether an application resource is empty
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: 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: 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: And the inserted tile (when I insert a non-zero-length file) looks like this: <% String directionsKey = (String) request.getAttribute("directionToUserKey"); %> 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: "> ... 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 > >classname="java.lang.String"/> > >class="java.lang.String"> > > > > >name="directionToUserString"/> > > > 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 in
Re: Test whether an application resource is empty
Try: "> ... 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 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___ 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]
RE: Test whether an application resource is empty
Well, that's certainly something I can consider for the future. For right now, our product is already pretty huge, and I think I would get shot if I tried to add another set of jars to the classpath, even if in the long run we'd be better off. The best solution I've been able to come up with is to punt: insert another tile to all of these screens, which is blank if there is no content and a small JSP page if there is content. If there is content, write it out with the usual tag. Does anyone have a better solution? This will be a pain, but I think it will work. Chris -Original Message- From: Benedict, Paul C [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 1:34 PM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty Chris, Struts contains an EL package for its tag libraries. Yes, you can use EL! But it doesn't matter if you're using Struts or not. If you're using a Servlet 2.3 container, you can use JSTL which you want to use. If possible avoid the and tags, and use JSTL instead. These are built with EL. -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 1:18 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Thanks for your help, Paul. I'm trying that, but I'm getting the same results as I did when I used originally. That is, I'm getting the key, not the value, so I still need to get the value to determine whether it's empty. But when I try to define a bean as the value of , it fails when that value is empty (which is what I was trying to check for in the first place!). The project I'm working on is using struts 1.1, so I don't think I have access to the EL tags -- am I mistaken? Chris -Original Message- From: Benedict, Paul C [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 12:17 PM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty Chris, Use to bring in the key. You can then use EL to test if it is empty or whatever. Thanks, Paul -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 11:37 AM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Importance: High I'm sorry to keep sending this over and over again, but I'm really stuck. If this isn't possible, could someone let me know? Then I could try to find an alternate path. Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 5:09 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ Siebel IT'S ALL ABOUT THE CUSTOMER Visit www.siebel.com This e
RE: Test whether an application resource is empty
Chris, Struts contains an EL package for its tag libraries. Yes, you can use EL! But it doesn't matter if you're using Struts or not. If you're using a Servlet 2.3 container, you can use JSTL which you want to use. If possible avoid the and tags, and use JSTL instead. These are built with EL. -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 1:18 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Thanks for your help, Paul. I'm trying that, but I'm getting the same results as I did when I used originally. That is, I'm getting the key, not the value, so I still need to get the value to determine whether it's empty. But when I try to define a bean as the value of , it fails when that value is empty (which is what I was trying to check for in the first place!). The project I'm working on is using struts 1.1, so I don't think I have access to the EL tags -- am I mistaken? Chris -Original Message- From: Benedict, Paul C [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 12:17 PM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty Chris, Use to bring in the key. You can then use EL to test if it is empty or whatever. Thanks, Paul -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 11:37 AM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Importance: High I'm sorry to keep sending this over and over again, but I'm really stuck. If this isn't possible, could someone let me know? Then I could try to find an alternate path. Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 5:09 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ 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] -- Notice: This e-mail message, together with any attachments, contains
RE: Test whether an application resource is empty
Thanks for your help, Paul. I'm trying that, but I'm getting the same results as I did when I used originally. That is, I'm getting the key, not the value, so I still need to get the value to determine whether it's empty. But when I try to define a bean as the value of , it fails when that value is empty (which is what I was trying to check for in the first place!). The project I'm working on is using struts 1.1, so I don't think I have access to the EL tags -- am I mistaken? Chris -Original Message- From: Benedict, Paul C [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 12:17 PM To: 'Struts Users Mailing List' Subject: RE: Test whether an application resource is empty Chris, Use to bring in the key. You can then use EL to test if it is empty or whatever. Thanks, Paul -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 11:37 AM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Importance: High I'm sorry to keep sending this over and over again, but I'm really stuck. If this isn't possible, could someone let me know? Then I could try to find an alternate path. Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 5:09 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ 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] -- Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If y
RE: Test whether an application resource is empty
Chris, Use to bring in the key. You can then use EL to test if it is empty or whatever. Thanks, Paul -Original Message- From: Chris Loschen [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 11:37 AM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty Importance: High I'm sorry to keep sending this over and over again, but I'm really stuck. If this isn't possible, could someone let me know? Then I could try to find an alternate path. Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 5:09 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ 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] -- Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Test whether an application resource is empty
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 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___ 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]
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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Test whether an application resource is empty
I'm sorry to keep sending this over and over again, but I'm really stuck. If this isn't possible, could someone let me know? Then I could try to find an alternate path. Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 5:09 PM To: Struts Users Mailing List Subject: RE: Test whether an application resource is empty I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ 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]
RE: Test whether an application resource is empty
I'm still spinning my wheels on this -- does anyone have any ideas? 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 anyone could help, I'd really appreciate it. Thanks! Chris -Original Message- From: Chris Loschen Sent: Wednesday, June 08, 2005 1:12 PM To: Struts Users Mailing List Subject: Test whether an application resource is empty Hi all, I'm using struts 1.1. I have localized application resources keys defined in my tiles definition file. In my JSP, I use the tiles attribute and then display the localized message using the key. However, in some cases, the localized value is empty: there is no value for that particular locale or that particular instance. In those cases, I want to avoid writing out the key at all, but I'm having trouble figuring out how to make that test. Specifically, I have tiles defs like this: Etc. And the localized values are something like tiles.main.admin.manageHierarchy.businessStruc.add.directionToUser= (so no value for that key). In my JSP, I've tried several ways to test whether the key value is null or the length is 0, but none of them have worked yet. For example: <% if(directionToUser != null && directionToUser.length()>0){ %> <% }%> Problem here is that directionToUser is the key, not the value, so it's never null, and I get the empty div tags I'm trying to avoid. So I tried variations like this: That one returned "Define tag can contain only one of name attribute, value attribute, or body content". I've tried lots of variations similar to that, but haven't struck upon the right one yet. This SEEMS like something which should be pretty simple, but I'm missing something. Any suggestions? Thanks! Chris Loschen ___ 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. ___ 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. ___ 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]