I solved the problem!!! Because the tag was used inside another tag (that
extends LoopTagSupport) this caused the expression (or rather the setter
method) to resolve to spaces for the very first iteration of the loop. As a
result the tag was trying to look up empty spaces in the resource bundle and
failed. I now trim and test for this in the tag so it just prints an empty
space when that happens and then all the other iterations worked
successfully.
Quite a stupid mistake that took a long time to resolve... Thanks for the
input and help!
On 6/27/07, Marius Botha [EMAIL PROTECTED] wrote:
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: taglibs-user@jakarta.apache.org
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.Techhttp://www.dotech.com/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]