multibox problem with constantly checked item
I'm using struts 1.1rc1 with Tomcat 4.0.6. I've got a logic:iterator on a list-valued property. I'm using a multibox to produce a bunch of checkboxes. The first item in the list is always checked when the page is rendered. What the heck could be going on? I have a reset method, and I've checked - it is being called. Removing the extraneous noise, here is what I'm doing. public class FooForm extends ActionForm { public FooBar[] getRowProperty() { ... } public String[] getOffsets() { return offsets; } public void setOffsets(String[] offsets) { this.offsets=offsets; } private String[] offsets; public void reset(ActionMapping ..., HttpServletRequest ...) { offsets=new String[0]; } } and in the JSP: ... I have a DisplayFoo action that instantiates the form bean and binds it to request scope via the attribute name "my-form-bean", and then forwards to the JSP (actually, forwards to a Tiles definition which uses the JSP). I have another ProcessFoo action that processes the data on a submit, and then forwards back to DisplayFoo for redisplay. No matter what I do, the very first item in the list is always displayed as checked. Also, no matter what I do to its state, it is the one item I can't process (I'm producing a list of things to be selected from for deletion, and the first item can never be deleted). I've traced through my code, and I still have absolutely no idea what is going on. Is this some known problem that other people have stumbled over? Thanks in advance Reid
Newbie question about caching data for forms
Hi all, I've been reading through a lot of the Struts info available on the web in various places, and I have a question I'm hoping one of you more experienced folks can answer. There is something simple that I think I'm still not getting. How, using the tag libraries of Struts, can I do the following: 1. If this is the first time that a user has visited the page, then the form isn't pre-populated with any values. The user just types in his/her desired form field values and hits submit. 2. If the webapp knows what the values should be, then the form is first pre-populated with data for the user to edit (e.g. if the user was on that page before but validation failed, so all the fields are pre-populated with the user's previously-submitted data). I think that somehow the html:form and/or bean:parameter tags are where I need to look. To make this more concrete, think of your standard login page. When the user first hits the app, they type in their username and password on some login.jsp page. If they screw up their password, they'll get sent back to the login.jsp page, but now to be nice we'll have the username field pre-populated. That was a simple example; extend it to complex forms where there is a lot of data to keep track of and multiple paths back to the form. In other words, what I'm looking for is the best (or at least typical) idiom for using the struts tag libraries and associated classes to capture the user data and bundle it not only for processing by its action but to also hand that bundle back to a JSP page if necessary. If somebody could show me a simple example of what the JSP page and appropriate fragments of some associated form and action class, I'd be muchly appreciative. I'd probably also begin to feel a little more clueful than I do at the moment... Thanks! Reid - Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctionsfor all of your holiday gifts!
Looking for a clean required-bean handler
Hi all! The more I did into Struts the more I like it. I have noticed something that has me scratching my head a bit, wondered if anybody else had come up with a clean solution. Struts has a nice clean approach to organizing code and behaviour after you click on something. In other words, if I have a form then I have a nice way in Struts to associate the handler with the form. If I have a URL then there are decent ways that I can maintain the destinations in the controller instead of in the html/jsp pages. All nice. What I don't see is a straight-forward way of indicating what I want *before* going to a JSP page. Ok, I know... that probably sounds a little odd. My point is simply this: my JSP pages are maintainable because they, as view artifacts, don't know much about each other. If I want may action classes to be just as maintainable then they can't know much about each other either. That is the thing I don't like about actions at the moment. The action figures out how to process the incoming data from the request *and* prepare the page/session/whatever context before going to the next page. An action can only do that if it *knows* what the next page will require. That means there is less point in having that transition information explicitly captured in struts-config.xml because I might have to know the same information implicitly in the action code. So, here is what I want, and I'm hoping somebody has already found a clean approach for it. Instead of only writing "process-X" actions, I also want to write some "prepare-for-Y" actions. Then any JSP page has potentially two actions; one executed as I head into the page (e.g. to prep dynamic content), the other executed as I head out of the page (e.g. for user response). The clean way I can think of is to have some kind of action that iterates over the beans that will be needed by the next page, i.e.: - step 1, if I don't have a UserBean, get me a UserBean - step 2, if I don't have a UserPrefsBean, get me one (etc) Then, you'd need some way of getting a controller-mediated way of recognizing that some particular action must be invoked to get a UserBean, etc., and then returning control back to the "prep" action. Once the prep action has everything it needs, it forwards to the next step. Is this crazy? Sane but not done before? Sane and done already? Inquiring minds want to know! Thanks Reid - Do You Yahoo!? Send your FREE holiday greetings online at Yahoo! Greetings.
Re: Looking for a clean required-bean handler
Francisco Hernandez <[EMAIL PROTECTED]> wrote: this sounds something like the "Pull" model where the jsps "Pull" the data they need rather then the "Push" model where the data is "Pushed" into the jsp.. hrmm.. checkout http://sourceforge.net/projects/webwork its "Pull HMVC" its worth a shot if i correctly understand what your trying to accomplish Thanks for the pointer, I'll check it out! I also had a few thoughts about a Struts solution on the train home. See if you think this makes sense. 1. Create "before" and "after" actions. 2. "after" actions look like what people are used to for processing forms in Struts, only a bit simpler. The job of an "after" action is to consume any form beans and generate appropriate side-effects *independent* of what the next page might be. So, in an EJB app you would make state changes, and in a login page you might stuff some kind of User javabean into the session context because you know all pages would go looking for it. Once done, the "after" action would look for a magic request parameter; if present that would provide the name of the next action (basically a return path), otherwise transition out in whatever way(s) would be normal for the action. 3. each "before" action only preps for the display of one particular JSP page and inherits from a base class that adds a bit of simple workflow support to the basic Action. All such subclasses provide lists of bean names to look for and the context in which they should be found. The parent class functionality iterates over those lists, and if anything is missing then the magic return parameter is set and an action is invoked to supply the missing bean. The action could be derived by applying a naming convention to the bean name (e.g. "myBean" -> "/before/myBean.do"). Once you have the required beans, you do any other setup work required for the page, and then forward to the JSP page. Now, there is some complexity to that magic return value that I'm glossing over, but aside from that I think this would work. It results in an extra "K" before action classes, where "K" is the number of web pages in your application. It would also end up with another "K" action mapping entries in struts-config.xml. On the other hand, all the after action classes would be simpler and more independent of each other. - Do You Yahoo!? Send your FREE holiday greetings online at Yahoo! Greetings.
Re: javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE
Jack <[EMAIL PROTECTED]> wrote: What causes this exception: javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE? I ran into this repeatedly trying to get Struts working within JBuilder. I found two things I had to fix: 1. Never rename 'struts.jar' (otherwise you break the OpenTool for JBuilder that removes Struts from the classpath before launching Tomcat) 2. Use the load-on-startup tag in web.xml (it shouldn't be necessary, and isn't if you deploy to a Tomcat server, but for some oddball reason seemed to sometimes matter when using the Tomcat integrated with JBuilder). - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
Re: The encoding "Cp1252" is not supported.
Anna Chen <[EMAIL PROTECTED]> wrote: Any one has idea about this error? FATAL: configuration error org.xml.sax.SAXParseException: The encoding "Cp1252" is not supported. I don't know why you are getting the error, but Cp1252 is the default character encoding for the assorted java.io reader classes on Win32 JVMs. - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
checkbox/iterate question
Ok, I admit to feeling a little thick-headed at the moment, given all the past traffic on checkboxes and iteration. I still am not getting it. Here is what I'm trying to do; can anybody give me the step-by-step-idiot-proof-recipe on how to do it? 1. I'm using Struts 1.0 (no patch, no nightly release), although I can change that if there is a reason to (we tend to use official releases unless there is a case for something newer a bloody-around-the-edges). 2. I have two actions; one executed before displaying the JSP so I can fetch data, one executed after the JSP so I can process the submitted form. 3. In the "before" action I fetch an unknown number of data records; could be zero, could be 100, who knows? Each record will be displayed by one row of an html table. I know how to use iterate to display this data. 4. For each row of that table I want to provide a checkbox. If the checkbox is checked when the form is submitted, it means I want the "after" action to keep the corresponding row, otherwise I don't want to keep the row. So, how do I do this? - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
Re: JDeveloper and Tomcat
I"m not a JDeveloper user, but as I recall it is (or at least was) an IDE based on JBuilder and licensed by Borland/Inprise to Oracle. If that is still the case then maybe you need to follow the same steps to integrated Struts with JDeveloper as you would for JBuilder. That means installing the open tool to add the *.tld files to the war you build and remove struts.jar from the Tomcat classpath. Try looking at: http://www.netstore.ch/mesi/strutsTutorial/ and ignore the stuff specific to WebLogic. "VEDRE, RANAPRATAP REDDY" <[EMAIL PROTECTED]> wrote: Has anybody integrated Tomcat with JDeveloper. I want to know if we can run struts application using Tomcat from JDeveloper. - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
Re: Execute_Struts_in_Netbeans?
This sounds a lot like the problems you see in JBuilder with integrated Tomcat. If so, then the problem is that your struts library is on the wrong classpath. You want it in the war's web-inf/lib directory, and only in that the classpath build from the war's contents. Unfortunately in an IDE you probably place the struts.jar on your classpath for builds... and (at least in JBuilder) that is the classpath you have when Tomcat is launched. The solution for JBuilder was that one of their developers created two opentool extensions; one stuffed the *.tld files in the war, the other removed struts.jar from the classpath before launching Tomcat. I don't know what the solution would be for Netbeans. AJ Morris <[EMAIL PROTECTED]> wrote: Has anyone had luck executing struts-based applications in the Netbeans integrated Tomcat? Things are fine with the standalone Tomcat, but not the internal Tomcat. - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
How to do an outcall but return to the session?
Hi all, I need to integrate an external web-based service with a Struts-based app. The chain of events are: 1. client invokes URL on my app within their current session. 2. My action class gets hit. Sometimes it would immediately forward to a JSP, but sometimes it must first bounce the user to the external service before doing the forwarding. 3. When I forward the user to the external service it is by doing a redirect, and I tell the external service where to send the user back to by tacking on an appropriately-formatted query parameter containing the return URL. When the user submits whatever is required by that service, the service sends them to that URL (i.e. back where they came from). 4. When the user gets back, they need to be in the same http session they were in before being bounced to the external service. Lots of stuff is bound to their session, and it would be a bad thing to have lost that context data. How do I do this in Struts? In particular, if I'm in an Action class and constructing an ActionForward object to toss the user to the external service, how do I make sure the session is preserved? Does that happen automatically via cookie magic, or do I need to extract a session id from somewhere and tack it on to the URL for the return? If the latter, how specifically do I do that? Thanks! Reid - Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
RE: How to do an outcall but return to the session?
I figured that was probably what would happen in the case of cookies. Is there an easy way to deal with the re-written url/disabled cookies case? I want to be sure the right thing happens whether or not cookies are enabled. Thanks! Alex Paransky <[EMAIL PROTECTED]> wrote: Assuming your client is using cookies this should work automatically. If your client has his/her cookies disabled you must make sure to submit a "re-written" url as the target for "returnTo" processing in your other system. - Do You Yahoo!? Yahoo! Auctions Great stuff seeing new owners! Bid now!
RE: How to redirect to login page
Jeff Oberlander <[EMAIL PROTECTED]> wrote: Set a session variable in first.jsp, then create a custom tag that checks for that session variable and place the custom tag in second.jsp and third.jsp. If the session variable isn't there, forward to first.jsp. The sample app does this exact process with the CheckLogonTag. Go look at how that works. Another alternative is used by the workflow extension listed on the Struts resources page. You can create a base action class that does the checking in its perform method, then calls some other method provided by the concrete subclass to do the normal work if the user is already logged in. In that extension package the "performAction" method is called. I like the architecture used by this package, but I don't like some aspects of the implementation. It invalidates the session if the user hasn't yet logged in (which is a serious pain if the user had logged in, but the session timed out), and it doesn't really have any support for looping back to where you started from by saving and restoring form data. The package also doesn't contain any licensing info, which tends to make the corporate legal eagles tres nervous. Reid - Do You Yahoo!? Yahoo! Auctions Great stuff seeking new owners! Bid now!