Re: Resource Bundle Problem (sometimes)

"Marius Botha" <[email protected]>
Newsgroups gmane.comp.jakarta.taglibs.user
Message-ID <[email protected]>
I tried both the super.pageContext and just pageContext, but neither works.
Is there any other way to do this? (In the examples people use other classes
than ExpressionEvaluatorManager so maybe I should use another one?). What I
cannot understand is why the same tag works fine on other pages, but the
moment I use it inside another tag the setter method sets a null/empty. I
have many other custom tags though that work just fine - just this one
(driving me crazy).

Shall I post the source?


On 6/26/07, Kris Schneider <[email protected]> wrote:
>
> Quoting Marius Botha <[email protected]>:
>
> > Thanks for the quick response.
> >
> > It seems like it could actually be the setter method that is the culprit
> > rather than the "resources.getString("key"));". If I do System.outs on
> "key"
> > (see below) I get the correct value every time I use the tag on its own
> in a
> > JSP (i.e. both key1 and key2 has a value), but the moment I use it in my
> > other tag the second value is null/empty. I think it's got something to
> do
> > with scope maybe ... but unsure what else to do as my other tags work
> fine
> > it is just this one...
> >
> >  public void setKey(String key) throws JspException {
> >   System.out.println("key1="+key);
> >   this.key = (String)ExpressionEvaluatorManager.evaluate("key", key,
> > String.class, this, super.pageContext);
> >   System.out.println("key2="+this.key);
> >  }
>
> Why are you passing "super.pageContext" instead of just "pageContext"?
>
> > Thanks again, much appreciated.
> >
> > -----Original Message-----
> > Kris Schneider <[email protected]> wrote:
> >
> > The stack trace seems to indicate that the property file is located just
> > fine,
> > but that the file does not contain a key called "key". If the property
> file
> > could not be located, ResourceBundle.getBundle() should be throwning the
> > exception, not ResourceBundle.getString().
> >
> >
> > -----Original Message-----
> > From: Marius Botha
> > [*mailto:[email protected]*<[email protected]>]
> >
> > Sent: 26 June 2007 03:40
> > To: [email protected]
> > Subject: Resource Bundle Problem (sometimes)
> >
> > Hi there,
> >
> > I have my own tag (extending BodyTagSupport) in which I do the
> following:
> >
> > <code>
> > ResourceBundle resources = ResourceBundle.getBundle("application");
> > out.print(resources.getString("key"));
> > </code>
> >
> > This works great ... most of the time. However, the moment I put this
> tag
> > into another tag that I wrote (a Data Table Tag - extending
> LoopTagSupport)
> > I get the following exception(below). For some reason it seems to find
> the "
> >
> > application.properties" resource file when my tag is on its own
> somewhere on
> > the JSP, but when I try to use it in another tag, it doesn't work. Any
> > ideas?
> >
> > Much appreciated.
> >
> > Marius Botha
> >
> > Exception:
> >
> > java.util.MissingResourceException: Can't find resource for bundle
> > java.util.PropertyResourceBundle, key
> > java.util.ResourceBundle.getObject(ResourceBundle.java:326)
> > java.util.ResourceBundle.getString(ResourceBundle.java:286)
> > com.workpool.struts.component.html.MessageTag.doEndTag(MessageTag.java
> :32)
>
> --
> Kris Schneider <mailto:[email protected]>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.