Re: Indexed properties
At 02:23 PM 7/25/2001 -0400, you wrote: Nathan, Hi. Currently you have to use my changed tags...but it looks like they will be in the nightly build by the end of the week. You can get them at http://husted.com/about/struts/indexed-tags.htm, and I attached some example source code to a previous message which was just mentioned, if you want to look at that. Cheers, Dave I have a couple of questions about your mods. At our site we are using a different set of modifications, posted by some other Struts user which seems to accomplish the same thing as your mods. The major difference seems to be that yours requires an additional attribute to specify that the particular input field is to use an indexed property accessor. I'm curious as to why you made this choice? The mods we are using automatically use an indexed accessor if the input field is contained inside of an iterate tag. Do you have an example of when you would have an input field inside of an iterate tag when you wouldn't want to use an indexed property name? (I'm not trying to argue with your decision, just trying to get a better understanding of your thoughts). The other issue, which we just came across today, with the other indexed property mod, is that it would fail to work correctly if you had iterators inside of iterators. We had a case where we used an iterator to access a collection of beans, and then iterated over the contents of each of the beans. The resultant HTML needed to look like this to work correctly: input type=text name=firstTable[n].secondTable[m].propertyName Will your mods handle nested iterators correctly? Finally, are your mods going to be part of the official build, or are they included in some sort of user supplied extensions? I missed the original discussion about your modifications. Thanks! James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Re: Indexed properties
At 05:20 PM 7/25/2001 -0400, you wrote: Hi James, Thanks for your note - made me think a bit! Would be interested in knowing more about the other indexed tags that were posted and you are using. I know either Jeff Trent or Martin Cooper had produced some tags which had a different name ie IndexedXXXTag. I believe the mods we have are based on those posted by Niall Pemberton. In those mods, a handful of HTML tags had their doStartTag() method modified to be changed from: results.append( name=\); results.append(this.property); to results.append( name=\); results.append(propertyName()); where propertyName() was implemented like this: protected String propertyName() { IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, IterateTag.class); return iterateTag == null ? this.property : iterateTag.getProperty() + [ + iterateTag.getIndex() + ]. + this.property; } In the original mods that we had, the getProperty method of IterateTag simply returned the property field value. I modified it to invoke a propertyName() method whose implementation is the same as that given above. This allows for a recursive buildup of indexed property fields when an HTML tag is included inside of any number of nested iterate tags. James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Running Tomcat+Struts w/o internet connection
We are trying to run Tomcat + Struts to run our web application without an external internet connection. We are running into a problem because our struts-config.xml has an external reference to the struts-config DTD. What is the proper way to modify struts-config.xml to reference a locally defined DTD and where would that file normally reside in a standard Tomcat installation? Thanks.
Accessing session attributes
This is probably a stupid question, but here it goes. I have a handful of string values that I'm storing in the session object. These values aren't associated with any bean (actually, in a sense the session object is the bean). I have a couple of places where I need to display these values in a form. I want to use the html:text tag, but I don't know what I need to specify. Let me give an example. Suppose I have a String value stored in the session by the name of filter. How would I get the filter value to display in a form text field? Thanks.
Editing tabular data
I'm currently in the process of coding a Struts-based JSP page which will let my user edit a table of values. I started out by creating a read-only display of values using the logic:iterate tag and bean:write tags. The object associated with the iterate tag answers a collection of beans and I have several bean:write tags which are used to display the properties of the bean. It looks something like this: logic:iterate id=bean name=beanCollector property=beanCollection tr td width=70bean:write name=bean property=prop1 filter=false//td td width=70bean:write name=bean property=prop2 filter=false//td [ more attributes ...] /tr /logic:iterate I'm now somewhat at a loss as to how to construct a screen which will let the user update any and all fields in the table and save them. Can anybody provide and example of how I might go about building a page which can edit a table of information? Thanks.
Usage of include or forward in Action definition
Could someone explain a little more about when you would want to use either the include or forward attributes of the action tag (used in struts-config.xml) instead of the type attribute? An example or two would go a long way to clarifying when and why someone might want to use either include or forward. Thanks.
RE: Returning from a form page
Thanks for the tip. I had considered doing something like that but somehow convinced myself that it probably wouldn't work before even giving it a try. At 02:42 PM 4/30/2001 -0700, you wrote: If you hard code a parameter into the href or page attribute of html:link, it is smart enough to know how to append the other parameters contained in your parameter map. For example if your page value is /myForm.do?ref=1, and your parameter map contains the pairs param1=abc and param2=def, html:link will correctly form the URL: http://www.mycompany.com/myApp/myForm.do?ref=1param1=abcparam2=def -Original Message- From: James Howe [mailto:[EMAIL PROTECTED]] Sent: Monday, April 30, 2001 11:44 AM To: [EMAIL PROTECTED] Subject: Returning from a form apge In our web application, we have two pages from which a user can access a third page. From the third page (which is form to fill out and save), the user either saves or cancels their action, and the user is returned to the page from which they originally started. However, the third page has no knowledge about where it came from so it doesn't no who to forward to when its action is complete. [...] James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Returning from a form apge
In our web application, we have two pages from which a user can access a third page. From the third page (which is form to fill out and save), the user either saves or cancels their action, and the user is returned to the page from which they originally started. However, the third page has no knowledge about where it came from so it doesn't no who to forward to when its action is complete. I'm not sure how best to handle this situation. One option would be to use a parameter on the link to the third page with a value indicating the page to return to. However, I'm using an html:link tag which is passing other object related parameters on to the third screen (the form uses this information to populate itself). What I would like to do is get the parameters from the object and then append another parameter which indicates the page to return to but I can't do that and use the link tag. I'm toying with the idea of building a custom link tag which also takes a return attribute. This tag would put the return information in the parameter list that gets generated. Before I do that, however, I'm wondering what other ways people have used to address this sort of problem? (I assume that I'm not the only person to have encoutered this situation) Any tips or suggestions would be appreciated. Thanks.
Re: Required vs. optional name attribute
At 10:00 PM 4/22/2001 -0700, you wrote: On Wed, 18 Apr 2001, James Howe wrote: I apologize in advance if this topic has come up before, but ... I'm building a Struts JSP page containing a form. I've noticed that the HTML tags typically do not require the specification of a name attribute in order to retrieve property values from a bean. If the name isn't specified, the property value is retrieved from the bean associated with the form. However, logic tags require the use of the name attribute in order to retrieve a property. [...] The HTML-oriented tags that allow you to default the name attribute can *only* be used within an html:form tag -- they are not useful in any other context. The logic tags (and the bean tags as well) are general purpose tools, useful either inside or outside a form. It would be technically feasible to do what you suggest, but IMHO it would be very confusing to have the same tag do two different things depending on whether you nested it or not. Craig I understand your point. How about if there were a new tag in Struts called defaultName (or something similar). In the defaultName tag, you could identify a bean which automatically be referred to by all other tags unless a different bean name attribute were specified on a tag. This would let you include common code and the common code wouldn't have to know the name of the bean from which it got its value unless it wanted to. James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Required vs. optional name attribute
I apologize in advance if this topic has come up before, but ... I'm building a Struts JSP page containing a form. I've noticed that the HTML tags typically do not require the specification of a "name" attribute in order to retrieve property values from a bean. If the name isn't specified, the property value is retrieved from the bean associated with the form. However, logic tags require the use of the name attribute in order to retrieve a property. Isn't there some way that the logic tags could look to see if there is a bean "in scope" and use that bean to retrieve property values from if no name attribute is specified? The problem I have is this, I have a portion of a form which is common to more than one form. I would like to factor out the common stuff into an include file of some sort. However, the common stuff makes use of a logic tag (notEqual). I can't factor out this code because I have to explicitly reference a specific bean name in order for this code to work. However, my various forms have different bean names associated with them. It's not a terribly big deal, but it seems as if the name attribute shouldn't have to be required if some sort of "default" bean is available for the page. Thanks.
Feature request
I'm using the bean:write tag to add parameters to a dynamically generated URL used by some javascript on my JSP page. The problem with bean:write is that it doesn't URL encode the result. In general, this is probably a good thing. However, there are times when it would be nice to have the value encoded. Would it be possible to add an additional optional tag to WriteTag which would indicate whether the result was to be URLEncoded? The default would be false which would not require any changes in current code. Also, if there is an alternative way to get this functionality, please let me know. Unfortunately I can't use the "link" tag in this circumstance. Basically I have a line in my file which looks like this: input type="button" ... onClick="self.location="foo.do?key='bean:write ...'" In other words, I'm building up the parameters to the location URL based on property values in a particular bean. Thanks.
Where are Struts messages found?
I'm working with Struts and I'm trying to build an error page for my JSP application. In looking at the Struts tag code I see statements which look like this: throw new JspException(messages.getMessage("getter.bean", beanName))); which looks like it should be populating the exception with some useful information. However, when I execute this code in a debugger, the message assigned to the Exception is null because there is no message with the name "getter.bean". Where would I find definitions for messages such as "getter.bean", "optionsTag.iterator", etc?
Re: Where are Struts messages found?
Nevermind. I found them in places like org/apache/struts/util/LocalStrings.properties. I'm running Tomcat/Struts from within VisualAge and I hadn't properly imported the Struts resources and I was missing these properties files. At 11:33 AM 4/11/2001 -0400, you wrote: I'm working with Struts and I'm trying to build an error page for my JSP application. In looking at the Struts tag code I see statements which look like this: throw new JspException(messages.getMessage("getter.bean", beanName))); which looks like it should be populating the exception with some useful information. However, when I execute this code in a debugger, the message assigned to the Exception is null because there is no message with the name "getter.bean". Where would I find definitions for messages such as "getter.bean", "optionsTag.iterator", etc? James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Re: Performance of struts
If Tomcat's performance is pretty awful, what are some JSP implementations (commercial or otherwise) that are particularly good? At 12:10 PM 3/19/2001 -0800, you wrote: Struts based apps (or any app that uses custom tags heavily) are going to be significantly impacted by the quality of the JSP implementation in your container. Which version are you using? (NOTE: Tomcat's performance w.r.t. JSP pages is pretty awful, for example). Thanks! keith Craig McClanahan James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Tips needed
The company I work for wants to create a web version of an existing application. We have created a static web site which we are using as the prototype for the real thing. We now need to make the site active. Can anyone offer any tips on good ways to convert a static web site into a Struts application? Thanks.
Re: Base tag question
At 05:35 PM 2/26/2001 -0800, you wrote: James Howe wrote: Is there some reason why the base tag defined in the HTML tag library doesn't let you specify the optional target attribute? I'm working with a frames based web application and I need to use both the href and target attributes. I know I could subclass the custom base tag, but before I do, I was wondering if there was any particular reason why the standard Struts base tag does let the user specify the target. I prefer not to support attributes that aren't in the official HTML 4.01 specs, and this is one of those. You're welcome to support it yourself in a subclass, however. Thanks. Craig I thought target was part of the spec. In looking at the spec on www.w3c.org, the following page specifically mentions the target attribute: http://www.w3.org/TR/html4/struct/links.html#edef-BASE However, the DTD does not mention the target attribute so I'm a bit confused. Perhaps target will be superceded by a style-sheet specification? If you don't want to change the base tag implementation I will just plan on creating my own subclass. Thanks. James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Base tag question
Is there some reason why the base tag defined in the HTML tag library doesn't let you specify the optional target attribute? I'm working with a frames based web application and I need to use both the href and target attributes. I know I could subclass the custom base tag, but before I do, I was wondering if there was any particular reason why the standard Struts base tag does let the user specify the target. Thanks.
Struts and Frames
I'm working to build a web based application using Struts. Currently we have a mocked-up prototype which uses frames (iframes in particular) to control what gets displayed on the screen. In general the format of our or pages consists of three frames: Top (header/navigation stuff) Main (the thing the user is currently doing) Footer I've tried to "strutsifiy" this prototype but I haven't quite figured out the best way to handle things. The one thing I did was convert the footer from "footer.html" to "footer.jsp". This lets me dynamically change the content of the footer. This seems to work. I then tried to modify the main body. I started by making the main body point to my "logon.do" action. This worked fine. The screen came up and my logon stuff was in the middle frame. However, once the user logged on, my middle pane went blank. In my config, I had the logon page forward to my success action, but my success action never displayed. Is there anything special I need to do to make my struts application usable in a framed environment? Thanks!
A couple more frames (and non-frames) questions
I have a couple more questions regarding Struts and frames as well as a question concerning web site organization. I was able to get my frames-based Struts application to sort of work after adding the "target" property to my logon form. This leads to my next question. My current page has the Navigation frame, the body frame and the footer frame. I had made my footer a jsp which was design to display information based on who the user logged in as. Before the user logs in, the foot is basically blank. I present the logon screen. Once the user logs on, I want to display a new page in the body frame, but I also want the footer to update. Unfortunately, it appears that when the logon form finishes transferring to the "success" page, only the body frame updates. (Not that this should be too surprising). My question is, how can I get the footer frame to update as well? Can I programatically get other frames to update when an action occurs? Or do I just need to restructure how my page works? Related to the above, the current structure of my web application has some pages at the root level and some in subdirectories. For example, my logon.jsp is in the root, but the jsp and html associated with the success action exists in a subdirectory. When I logged into my application, I was able to most of the contents of my next page to display, but not everything. I also had to tweak some of the paths in my html. For example, previously I had a reference to a style sheet as "../style.css". When the page was displayed, the style was not applied. If I changed the reference to "style.css", the style was correctly applied.However, my page also referenced an html file for one of its frames. This page never appeared, and no error was displayed either. I'm sort of confused as to where the system thinks it is after performing a forward action. I'm sure I could get everything to work if I just put it all in the root directory, but I'm not sure that's what I want to do. Can anyone offer any suggestions on good ways to organize Struts applications? Thanks again.
Re: which development tool to use?
We also use VAJ 3.5 with Tomcat and Struts. It's nice to be able to develop, run, and debug within the same environment. Since the generated JSP code is part of the IDE, it's a simple matter to put breakpoints in the generated JSP if necessary. At 11:24 PM 2/5/2001 +0100, you wrote: I use VAJ 3.5 with Tomcat and struts. works perfectly can debug throught the jsp's (not really jsp's but the generated servlets) Can change code on the fly without restarting anything. johan James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Is request shared across a redirect?
I have two JSP pages which I want to have share a bean. In the first JSP page I do something like this: [...] jsp:useBean id="bean" scope="request" class="package.BeanClass"/ jsp:setProperty name="bean" property="prop" value='Some Value'/ logic:redirect href="foo.jsp"/ [...] In "foo.jsp", I have code which looks like this: [...] logic:notPresent name="bean" scope="request" h3Message not available/h3 /logic:notPresent logic:present name="bean" scope="request" jsp:useBean id="bean" scope="request" class="package.BeanClass"/ h3bean:write name="bean" property="prop" filter="true"//h3 /logic:present [...] When I invoke the first page, I make the transition to the second page, but the bean property is never found. I've debugged the code and it appears that the request object used by the second page does not have the attribute defined by the first page. I guess I thought that objects put into the request scope were maintained across a redirection. Was I wrong or am I just doing something stupid? Thanks.
Re: Is request shared across a redirect?
Certainly makes sense. I was able to change to using forward and now I'm getting the results I expected. Thanks! At 02:51 PM 1/31/2001 -0500, you wrote: Requests are not preserved over a redirect because this generates a redirect response back to the browser. The browser responds by requesting the URL provided in the redirect response. Request and response objects are preserved over forward because this is internal to the webserver. -- Jason James Howe wrote: I have two JSP pages which I want to have share a bean. In the first JSP page I do something like this: [...] jsp:useBean id="bean" scope="request" class="package.BeanClass"/ jsp:setProperty name="bean" property="prop" value='Some Value'/ logic:redirect href="foo.jsp"/ [...] In "foo.jsp", I have code which looks like this: [...] logic:notPresent name="bean" scope="request" h3Message not available/h3 /logic:notPresent logic:present name="bean" scope="request" jsp:useBean id="bean" scope="request" class="package.BeanClass"/ h3bean:write name="bean" property="prop" filter="true"//h3 /logic:present [...] When I invoke the first page, I make the transition to the second page, but the bean property is never found. I've debugged the code and it appears that the request object used by the second page does not have the attribute defined by the first page. I guess I thought that objects put into the request scope were maintained across a redirection. Was I wrong or am I just doing something stupid? Thanks. James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Initializing a Struts application
I'm a little confused about how to best initialize some application scope information in a Struts application. For example, I need to configure a handful of IP addresses which my beans need to talk to. I might do something like this in a configuration file: marketData=127.0.0.1 My question is where to put this information. If I were writing a normal servlet application I would probably define this in the init operation. One option I've considered is to subclass from ActionServlet and add my own custom initialization tags which I can use in my web.xml file. What I'm trying to figure out is how to best initialize a set of application scope variables for my struts application. Any suggestions would be appreciated. Thanks.
Possibly Stupid Question
I want to generate a link tag for a page which takes three parameters. The values of the parameter come from a bean which is available to the page. The end result should look something like this: a href="foo.do?parm1=val1parm2=val2parm3=val3"Link/a The values for val1, val2 and val3 come from a bean which happens to be the current bean for an iterate tag. In other words, I'm going to have a table of items and each cell in the table is going to have unique values for the parameters. What is the easiest way to do this using struts? I've used the form:link tag before, but I think I can only pass one parameter with this tag. I've tried using snippets of java code ("%= bean.getFoo() %" for example) but this code ended up being quite verbose because I had to cast "bean" to the proper type before I could call "getFoo()". I'm thinking there must be a cleaner way to handle this situation. The only other way I've thought about would be to have the bean answer an "optionsString" as one of its properties, but I would rather not have that code in my bean. Thanks for any suggestions.
Possibly Stupid Question
I want to generate a link tag for a page which takes three parameters. The values of the parameter come from a bean which is available to the page. The end result should look something like this: a href="foo.do?parm1=val1parm2=val2parm3=val3"Link/a The values for val1, val2 and val3 come from a bean which happens to be the current bean for an iterate tag. In other words, I'm going to have a table of items and each cell in the table is going to have unique values for the parameters. What is the easiest way to do this using struts? I've used the form:link tag before, but I think I can only pass one parameter with this tag. I've tried using snippets of java code ("%= bean.getFoo() %" for example) but this code ended up being quite verbose because I had to cast "bean" to the proper type before I could call "getFoo()". I'm thinking there must be a cleaner way to handle this situation. The only other way I've thought about would be to have the bean answer an "optionsString" as one of its properties, but I would rather not have that code in my bean. Thanks for any suggestions.
New version confusion
I downloaded the nightly build of 01/03/2001 and I'm now having a problem with some of my JSP pages. Previously I was using a nightly build from 12/15/2000. For example, I'm now getting the message: Since tag handler class org.apache.struts.taglib.form.LinkTag does not implement BodyTag, it can't return BodyTag.EVAL_BODY_TAG I'm assuming that I've either not updated all the various bits correctly, or there has been a change in one or more of the tags that I need to account for. Can anyone offer any help? Thanks.
Re: New version confusion
At 05:34 PM 1/4/2001 +0100, you wrote: Since tag handler class org.apache.struts.taglib.form.LinkTag does not implement BodyTag, it can't return BodyTag.EVAL_BODY_TAG I'm assuming that I've either not updated all the various bits correctly, or there has been a change in one or more of the tags that I need to account for. Can anyone offer any help? Remove all your working dirs of tomcat (or whatever you use) the JSP files need to be generated again. That solved at my place the same problem. johan Thanks. That did the trick. James W. Howe mailto:[EMAIL PROTECTED] Allen Creek Software, Inc. pgpkey: http://ic.net/~jwh/pgpkey.html Ann Arbor, MI 48103
Page Forwarding Question
In my action classes I have code which checks to see if a user has logged on. If not, the code forwards to the logon page (e.g. servlet.findForward("logon")). However this doesn't fully accomplish what I would like. If a user attempts to reference a page which requires a login, I would like to forward to the login page and, once the user has authenticated, proceed back to the page to which the user was going in the first place. In other words, I would like to forward to the logon screen, but give it a parameter which it uses to tell it which page follows the logon.Can anyone suggest a simple way to accomplish this? Thanks.