Re: Resource Bundle Problem (sometimes)
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.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Resource Bundle Problem (sometimes)
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]
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)
Re: Resource Bundle Problem (sometimes)
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); } 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)
RE: How to print an int with a c:out tag?
Thanks guys, I tried that and got a new error (below). I will probably just go the scriptlet route for now as maybe I have an old or incorrect JAR somewhere. Can any one tell me where the TagLib for FN is? What I did: 1. Changed web-app ... as per example. 2. Included FN taglib in my web.xml file as I do with the other ones I use: taglib taglib-uri/tags/fn/taglib-uri taglib-locationhttp://java.sun.com/jsp/jstl/functions/taglib-location /taglib taglib taglib-uri/tags/jstl-core/taglib-uri taglib-location/WEB-INF/c.tld/taglib-location /taglib Then I get File http://java.sun.com/jsp/jstl/functions; not found, OR, If I don't import the taglib in my web.xml file and just try to use it, I get: The attribute prefix fn does not correspond to any imported tag library Thanks again for you patience, you've been a great help and I've learned quite a bit. Thanks, Marius -Original Message- From: Christian Taylor [mailto:[EMAIL PROTECTED] Sent: 02 August 2005 07:59 To: Tag Libraries Users List Subject: Re: How to print an int with a c:out tag? My next guess was going to be one thing mentioned on the page Murray links to below. Regardless of whether you are using Tomcat 5, JSTL 1.1 and JSP 2.0... if your web.xml doesn't say it's a servlet 2.4 app it will revert to Servlet 2.3/JSP 1.2 (and trying to use JSTL 1.1 with JSP 1.2 probably introduces many other problems...). As the page says, make sure your webapp element starts like this: web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 Otherwise the container will assume the servlet 2.3 spec and EL will not be allowed outside of JSTL (1.0) tags. The fn:length() function I originally mentioned is part of JSTL 1.1 anyway so it sounds like you just need to make sure everything is configured for the current specs and you should be good. Hope that will fix it up for you. -Christian Murray Steele wrote: Perhaps this page might provide the solution? http://www.oreillynet.com/cs/user/view/cs_msg/32931 Wrong taglib uri's or wrong webapp specification in your web.xml. Muz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to print an int with a c:out tag?
Thanks, I'll try that. Cheers, Marius -Original Message- From: Christian Taylor [mailto:[EMAIL PROTECTED] Sent: 02 August 2005 01:08 To: Tag Libraries Users List Subject: Re: How to print an int with a c:out tag? Hi Marius, Check out the fn:length() function, this is what you are looking for. size() is a method and you cannot call methods directly from JSTL (only getters and setters), but the fn taglib provides a function for length of Collections and strings. See the JSTL 1.1 documentation for more information, but basically fn:length() is what you are looking for: c:out value=${fn:length(myList)}/ Hope this helps. -Christian Marius Botha wrote: Hi there, Just a basic question. I am trying to print out the size() of a List, like the tag below. c:out value=${myList.size}/ But I am getting the following error: An error occurred while evaluating custom action attribute value with value ${myList.size}: The . operator was supplied with an index value of type java.lang.String to be applied to a List or array, but that value cannot be converted to an integer. (null) Can the c:out tag not print int's or is it that I am calling size() which does not have a getter/setter method? Please help. Thanks, Marius - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to print an int with a c:out tag?
My requirement is really a bit different. I have an expression, which returns a List, the size of which I would like to display. I.e. I have ${myController.activitiesForResource}, which returns a list. If I try c:out value=${fn:length(${myController.activitiesForResource})}/ I get an error saying EL expressions are not supported. Any ideas? Thanks, Marius -Original Message- From: Christian Taylor [mailto:[EMAIL PROTECTED] Sent: 02 August 2005 01:08 To: Tag Libraries Users List Subject: Re: How to print an int with a c:out tag? Hi Marius, Check out the fn:length() function, this is what you are looking for. size() is a method and you cannot call methods directly from JSTL (only getters and setters), but the fn taglib provides a function for length of Collections and strings. See the JSTL 1.1 documentation for more information, but basically fn:length() is what you are looking for: c:out value=${fn:length(myList)}/ Hope this helps. -Christian Marius Botha wrote: Hi there, Just a basic question. I am trying to print out the size() of a List, like the tag below. c:out value=${myList.size}/ But I am getting the following error: An error occurred while evaluating custom action attribute value with value ${myList.size}: The . operator was supplied with an index value of type java.lang.String to be applied to a List or array, but that value cannot be converted to an integer. (null) Can the c:out tag not print int's or is it that I am calling size() which does not have a getter/setter method? Please help. Thanks, Marius - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to print an int with a c:out tag?
You know your stuff hey :) I believe I do use Tomcat 5 (running inside JBoss 3.2) and as a result have their JSTL (looks like 1.1) and JSP-2.0.jar. Where do I find or can I check if I have the TLD for the functions library (so I can include it if missing)? At the moment I am including the TLD's in my WAR project and specify them in the web.xml file. Thanks again. Marius -Original Message- From: Murray Steele [mailto:[EMAIL PROTECTED] Sent: 02 August 2005 02:31 To: Tag Libraries Users List Subject: Re: How to print an int with a c:out tag? I suspect that you are using either Tomcat 4.1.x and / or Standard 1.0x for your JSTL. EL functions are part of the JSTL 1.1 spec (JSP 2.0) and aren't supported on Tomcat 4.1.x or Standard 1.0x (JSP 1.2 and JSTL 1.0 respectively). If you want to use the fn:length you need to use JSTL 1.1 and hence Standard 1.1 and / or Tomcat 5.x. (I think those versions are correct, someone correct me if I'm wrong). If you cant change the version of Tomcat / JSTL you use: 1. You could alter your myController.getOpenActivitiesForResource method to return a class that extends list to provide a getSize() (and hence your original c:out value=${myList.size}/ would work. 2. Find some other Tag lib that lets you output list sizes. (unstandard from the sandbox does this) 3. Just use a scriptlet %= ((MyControllerClass) pageContext.findAttribute(myController)).getOpenActivitiesForResource( ).size() %. Muz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Dynamically adding components to pages
Hi there, Hope someone can help me. I have a requirement where my system needs to prompt users for certain information at certain times in a process. To do this I need to be able to add components to a page at run time based on a user's permissions. E.g. if the user is supposed to specify a date for the process to continue, I need to provide a calendar control; and if the user needs to enter a name, then provide a textbox. I have developed my own custom tags that I would want to use but I have the following questions: 1. How do I reuse my components in such an environment? I suppose I would need to provide a StringBuffer or something to my component to write to (how?) and then call the doStartTag(), etc. methods manually? 2. How do I implement this in the JSP, seeing as the html/tags would have to be inserted at a certain stage. Has anyone done this before or can you give me any pointers? Much appreciated. Marius Botha - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Creating a custom Iterate Tag
Thanks. Are you referring to http://www.displaytag.org, http://displaytag.sourceforge.net/ or another ?? In the end I just did the following: Created 4 tags as below, where the tree tag writes out the containing HTML, the nodeIcon allows the JSP developer to define icons to use depending on the type of tree node and then the iterator just iterated (so no need to write out HTML). The displayNode tag painted the node depending on its content and context. tree:tree name=myTree traverserAction=/tree/tree.do targetFrame=main defaultNodeClass=defaultNode selectedNodeClass=selectedNode cellpadding=1 cellspacing=0 border=1 width=100% styleClass=myTable tree:nodeIcon type=String srcDefault=/folder.gif srcSelected=/folder2.gif / tree:nodeIcon type=Integer srcDefault=/people.gif srcSelected=/folder2.gif / tree:iterator var=node traverser=${treeTraverser} tree:displayNode node=${node}/ /tree:iterator /tree:tree -Original Message- From: Karl Coleman [mailto:[EMAIL PROTECTED] Sent: 21 January 2005 09:37 To: Tag Libraries Users List Subject: RE: Creating a custom Iterate Tag Check out the display tag. Google should tell you where to get it. You essentially just give it a collection and it writes all of the html to display it in a table. Karl -Original Message- From: Marius Botha [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 19, 2005 5:29 AM To: 'Tag Libraries Users List' Subject: RE: Creating a custom Iterate Tag Hi Felipe, Thanks for the response. I had a look, but my challenge is that I would like the iterating tag to write out HTML as well, not just iterate through the collection. I.e. the tag handler should create the surrounding table tags and when it iterates over the elements, they will create the TR and TD elements if required. I don't see an example or where I can find an iterating tag with like a doStartTag() and doEndTag() method that works to do this. I must be missing something... Thanks, Marius -Original Message- From: Felipe Leme [mailto:[EMAIL PROTECTED] Sent: 19 January 2005 01:54 To: Tag Libraries Users List Subject: Re: Creating a custom Iterate Tag On Tue, 2005-01-18 at 13:08, Marius Botha wrote: I need some guidance with creating a custom iterate tag (literally like the standard IterateTag, but where I can control what happens). I tried to find good examples or tutorials on how to do this, but couldn't find anything good so please advise if you know of anywhere good to look that is up to date. Have you tried the examples that comes with the Jakarta Standard Taglibs? They have such example... -- Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Creating a custom Iterate Tag
Hi Felipe, Thanks for the response. I had a look, but my challenge is that I would like the iterating tag to write out HTML as well, not just iterate through the collection. I.e. the tag handler should create the surrounding table tags and when it iterates over the elements, they will create the TR and TD elements if required. I don't see an example or where I can find an iterating tag with like a doStartTag() and doEndTag() method that works to do this. I must be missing something... Thanks, Marius -Original Message- From: Felipe Leme [mailto:[EMAIL PROTECTED] Sent: 19 January 2005 01:54 To: Tag Libraries Users List Subject: Re: Creating a custom Iterate Tag On Tue, 2005-01-18 at 13:08, Marius Botha wrote: I need some guidance with creating a custom iterate tag (literally like the standard IterateTag, but where I can control what happens). I tried to find good examples or tutorials on how to do this, but couldn't find anything good so please advise if you know of anywhere good to look that is up to date. Have you tried the examples that comes with the Jakarta Standard Taglibs? They have such example... -- Felipe - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Creating a custom Iterate Tag
Hi there, I need some guidance with creating a custom iterate tag (literally like the standard IterateTag, but where I can control what happens). I tried to find good examples or tutorials on how to do this, but couldn't find anything good so please advise if you know of anywhere good to look that is up to date. Previously I developed a class called TreeTraverserTag which extends TagSupport. It takes the following attributes name, traverser, etc. and then paints a pretty Windows like tree with multiple level nodes in the browser based on the tree structure. Now however I want to change this tag to instead iterate over the nodes and write HTML based on each nodes properties (like a different colour or icon based on type, etc.). Please advise which class to I need to extend or interface I need to implement so I can control the next(), hasNext(), etc. methods (as the tree is hierarchical with nodes that can expand or collapse, therefore not a standard collection or Array) as well as being able to write out the HTML for each iteration. Examples or tutorials would be welcome. I tried a couple of classes and interfaces but ran into problems due to a lack of experience. Things like the doAfterBody method was never called , or it went into a loop, etc. At the moment my tag looks like this: t:tree name=myTree traverser=${treeTraverser} defaultNodeClass=defaultNode defaultNodeImgageUrl=/folder.gif selectedNodeClass=selectedNode selectedNodeImgageUrl=/folder2.gifcellpadding=1 cellspacing=0 border=1 width=100% styleClass=myTable /t:tree Ultimately I want to do something like this (if it is possible): t:tree name=myTree var=node traverser=${treeTraverser} icon name=blue src=blue.gif/ icon name=red src=red.gif/ c:if test=${node instanceOf Document} DISPLAY RED /c:if c:if test=${node instanceOf Resource} DISPLAY BLUE /c:if /t:tree Much appreciated. Kind regards, Maruis Botha - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]