preselect dropdown
Hello, I have an edit.jsp where a user can edit message details. So for example, if a message has a start date (day,month, year) these fields can be updated by user. The problem is that I have dropdowns for month and day. I would like it if the dropdown for month could be prepolutated with the value the user has allready saved before. So for example it could be prepoluted with February and the user can select another value from the dropdown if he/she wishes to change it. Any ideas/hints/code would be helpful, thanks, Anna - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
editing a form
Hello, The user wishes to edit a message that was previously created. In my edit.jsp I wish to display a dropdown with the option that was previously selected as selected. Currently I have: html:select property=expiryDay html:options collection=days property=idValue labelProperty=displayValue / /html:select I want the value of expiryDay from the database to be selected (by default) on the dropdown. The user can select another option from the dropdown if they want to change it... how do i do it in struts? any help appreciated, Anna - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Trouble with struts validator
Why do you have a testAction? When you configure validation.xml and validator-rules.xml (see Apache/Struts/Validator documentation) you don't need to write an Action Class. Also, why do you have failure/success forwards? Upon a failure, the validation will automatically forward your page to the input you specified in your struts-config siteForm.jsp , with the errors redisplayed. If you post some code, maybe we can help more... Anna:) From: yacout dadoun [mailto:[EMAIL PROTECTED] Sent: Wed 06/10/2004 11:54 AM To: [EMAIL PROTECTED] Subject: Trouble with struts validator Hi, I'm trying to use the struts validator, i have created a simple form with few inputs, i'd like to oblige the user to enter values into inputs. I therefore : 1-added the validator pluing to strus-config.xml 2-added the action mapping with the path set to test, the type set to the path of the action form called TestAction, the name set to testForm, validate set to true and inut set the the jsp file called siteForm.jsp and forwards success and failure 3-created the TestAction.java taht extends Action and returns success 4-created the TestForm bean that extends ValidatorAction 5-created the testform.jsp added html:errors/whose fomr id is testForm 6-get teh applictaion.properties file from the struts blank project 7-in the validation.xml added the formset where the name is testForm and properties are required However no errors is displayed Any idea PLS Thanks _ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. - 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: populate html:select
Yes, I was using the old option tag but now html:option works like a charm... thanks :) From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Fri 01/10/2004 4:03 PM To: Struts Users Mailing List Subject: Re: populate html:select From: Anna Kerekes [EMAIL PROTECTED] Just the select list information is gone, all the textbox information is preserved on the form. Thanks for confirming that. If you want Struts to remember the selected items, then you MUST use Struts tags to display those items, html:option and html:options in this case. Both of those tags have an array of attributes, and it's not always clear which ones you need to use in combination to make it do what you want. The simplest thing to do would be to change all of your option tags to html:option tags. From your original note, it looks like you're hard-coding the options as plain-old-HTML option tags. Let us know if that's not the case. -- Wendy Smoak - 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]
input form
Hello, I have a jsp (create.jsp), a form-bean (CreateMessageForm.java), and an action (CreateMessageAction.java). Currently, the user inputs their info into create.jsp, hits 'submit', and the action gets the info from the form-bean and does stuff with it. Instead, I would like to get some information( collections) from a database and populate create.jsp with them. So I would like to: - get a collection from the database - put this collection into the request - populate create.jsp from the request object - let the user edit the form (including the pre-populated parts) - hit submit - CreateMessageAction gets info from form-bean and does stuff... Do I have to write a separate Action class for putting the collection (from database) into the request object? Or can I somehow incorporate this into my current CreateMessageAction class ? please help, Anna Kerekes - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
validator-rules.xml behaviour
Hello, I am trying to add my own custom validation method to my validator-rules.xml file. Here's the new snippet I am adding (Validator is a utility class I wrote to perform extra validation): validator name=dateCheck classname=com.onx.usermanager.util.Validator method=validateDate methodParams=java.lang.Object msg=error.date.invalid / I have tried debugging my code, the validator does indeed go into my validateDate method and returns a boolean=false. However, contrary to what I believed was going to happen, it does not throw the error.date.invalid is this not what is supposed to happen by default if the validator returns a false boolean? I think everything else is fine, in my jsp I have tdhtml:errors property=date//td and in my validation.xml: field property=date depends=dateCheck /field and in my ApplicationResources.properties file I have: error.date.invalid=lifont color=redEnd Date must be after Start Date/font/li Please help me, any help is appreciated, you can email me directly at [EMAIL PROTECTED], thanks, Anna p.s. I can do other validations with my xml files fine, it is just this custom one not working... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validator-rules.xml behaviour
Yes, thanks very much, that worked out great! Anna:) From: Matt Bathje [mailto:[EMAIL PROTECTED] Sent: Fri 01/10/2004 10:58 AM To: Struts Users Mailing List Subject: Re: validator-rules.xml behaviour In your validateDate method, are you doing an errors.add before returning false? If not, no message will be put into the errors object to be printed out. In my custom validators, I have the methodParams looks like this: methodParams=java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest and then do this in the method right before returning false: errors.add(field.getKey(), Resources.getActionMessage(request, va, field)); The other thing may be to try taking the property attribute off of your html:errors tag. Matt Anna Kerekes wrote: Hello, I am trying to add my own custom validation method to my validator-rules.xml file. Here's the new snippet I am adding (Validator is a utility class I wrote to perform extra validation): validator name=dateCheck classname=com.onx.usermanager.util.Validator method=validateDate methodParams=java.lang.Object msg=error.date.invalid / I have tried debugging my code, the validator does indeed go into my validateDate method and returns a boolean=false. However, contrary to what I believed was going to happen, it does not throw the error.date.invalid is this not what is supposed to happen by default if the validator returns a false boolean? I think everything else is fine, in my jsp I have tdhtml:errors property=date//td and in my validation.xml: field property=date depends=dateCheck /field and in my ApplicationResources.properties file I have: error.date.invalid=lifont color=redEnd Date must be after Start Date/font/li Please help me, any help is appreciated, you can email me directly at [EMAIL PROTECTED], thanks, Anna p.s. I can do other validations with my xml files fine, it is just this custom one not working... - 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]
populate html:select
Hello, I am using struts validation to validate an input form. In my jsp I have: html:select property=effectiveDay option value=1 selected1 option value=22 option value=33 option value=44 /html:select The form is filled out. After I hit the submit button Struts validation is run and the input form is displayed again with the errors on the form. The problem is that the value selected from the drop-down menu (i.e. html:select) before the submit button was hit is NOT preserved on the form with the validation errors. So the user has to re-enter whatever value he/she entered before validation. This is annoying..is there a way I can make it so that the hmtl:select could be populated with the value that was entered before (if any). I suspect that this value is stored somewhere (in request scope?) but I'm not sure how to get it. What is strange is that other fields on my input form are preseved (i.e. textboxes, and textareas) but not drop-down menus, checkboxes, and file. any help appreciated, Anna:) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: populate html:select
This case is different from the regular use of html:option because this information is never saved to a Collection (since the validation failed).. so this information about the dropdown menu needs has to be retrieved from the request scope or some other place From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Fri 01/10/2004 2:35 PM To: Struts Users Mailing List Subject: Re: populate html:select From: Anna Kerekes [EMAIL PROTECTED] Hello, html:select property=effectiveDay option value=1 selected1 ... The problem is that the value selected from the drop-down menu (i.e. html:select) before the submit button was hit is NOT preserved on the form You need to use Struts tags for the options if you expect the framework to pre-fill the form. Take a look at html:option and html:options which you can use with various attributes including creating the lists from a Collection. -- Wendy Smoak - 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: populate html:select
Just the select list information is gone, all the textbox information is preserved on the form. From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: Fri 01/10/2004 3:38 PM To: Struts Users Mailing List Subject: Re: populate html:select From: Anna Kerekes [EMAIL PROTECTED] This case is different from the regular use of html:option because this information is never saved to a Collection (since the validation failed).. so this information about the dropdown menu needs has to be retrieved from the request scope or some other place What information-- the contents of the drop-down, or the item(s) the user selected? Is *all* of the user input gone if the form fails validation, or just this select list? -- Wendy Smoak - 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]
validator-rules.xml
Does anyone know where I can get a copy of this file? In its default form? thanks, Anna - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: standard-1.1.1 expression language not working
I don't think you're using the set tag properly. Try: c:set var='a' value=1/c:out value='${a}'/ hope it helps, Anna Kerekes From: Pedro Salgado [mailto:[EMAIL PROTECTED] Sent: Mon 20/09/2004 1:15 PM To: Struts Users List Subject: standard-1.1.1 expression language not working Hi to everyone! I have already used taglibs before but I am having some trouble making jstl core 1.1.1 taglib to evaluate expression languages on Tomcat 5.0.27. I have all of the required libraries on WEB-INF/lib/ (jstl, standard, jdbc_2_0_stdext, xalan and xerces). Tomcat does not give any missing taglib handler... so I supposed it finds all of the necessary classes. I am also using Struts and Struts-el taglibs and they are working correctly. Am I missing something? my jsp file: %@ taglib uri=/WEB-INF/tld/struts-html-el.tld prefix=html % %@ taglib uri=/WEB-INF/tld/struts-logic.tld prefix=logic % %@ taglib uri=/WEB-INF/tld/struts-bean.tld prefix=bean % %@ taglib uri=http://java.sun.com/jsp/jstl/fmt; prefix=fmt % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % %@ taglib uri=/WEB-INF/tld/struts-tiles.tld prefix=tiles % %@ taglib uri=/WEB-INF/tld/struts-tiles-el.tld prefix=tiles-el % ... c:set var='a'1/c:setc:out value='${a}'/ (the output is ${a}) ... my web.xml, taglib declaration: taglib taglib-uri/WEB-INF/tld/struts-html.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-html-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-html-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-logic-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-logic-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-bean-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-bean-el.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/struts-tiles-el.tld/taglib-uri taglib-location/WEB-INF/tld/struts-tiles-el.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/fmt/taglib-uri taglib-location/WEB-INF/tld/fmt-1.1.1.tld/taglib-location /taglib taglib taglib-urihttp://java.sun.com/jsp/jstl/core/taglib-uri taglib-location/WEB-INF/tld/c-1.1.1.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-el-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-el-12.tld/taglib-location /taglib taglib taglib-uri/WEB-INF/tld/displaytag-12.tld/taglib-uri taglib-location/WEB-INF/tld/displaytag-12.tld/taglib-location /taglib - 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]
set not working
Hello, I am having some problems running the program below (it does not run the way it should). *The output I get is*** before a a is null after a *The desired output is before a init after a I'm not sure why ${a} is evaluating to null instead of init. any help appreciated, Anna Program: %@ page contentType=text/html;charset=UTF-8 language=java % %@ page import=java.lang.String % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % HTML % String a = init; % html:text property=var value=%= String.valueOf(a) % /br c:out value=before a / c:out value=${a} default=a is null/ c:out value=after a / /HTML - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: set not working
The first way works..thankyou However, the second way does not :( I get the following error: exception: javax.servlet.ServletException: javax/servlet/jsp/el/VariableResolver root cause: java.lang.NoClassDefFoundError: javax/servlet/jsp/el/VariableResolver Any ideas? From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Mon 20/09/2004 2:56 PM To: Struts Users Mailing List Subject: Re: set not working % java.lang.String a = init; request.setAttribute(a,a); % c:out value=${a} / or c:set var=a value=init / c:out value=${a} / Mark On 20 Sep 2004, at 20:16, Anna Kerekes wrote: Hello, I am having some problems running the program below (it does not run the way it should). *The output I get is*** before a a is null after a *The desired output is before a init after a I'm not sure why ${a} is evaluating to null instead of init. any help appreciated, Anna Program: %@ page contentType=text/html;charset=UTF-8 language=java % %@ page import=java.lang.String % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % HTML % String a = init; % html:text property=var value=%= String.valueOf(a) % /br c:out value=before a / c:out value=${a} default=a is null/ c:out value=after a / /HTML - 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: set not working
No, I'm getting the same HTTP Status 500 error as before... I've also tried all the different scopes in the set tag, but no luck Does the var have to be in a specific format? Is there anything else I can try? From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Mon 20/09/2004 4:35 PM To: Struts Users Mailing List Subject: Re: set not working Interesting.. what about c:set var=a value=${'init'} / ? On 20 Sep 2004, at 21:01, Anna Kerekes wrote: The first way works..thankyou However, the second way does not :( I get the following error: exception: javax.servlet.ServletException: javax/servlet/jsp/el/VariableResolver root cause: java.lang.NoClassDefFoundError: javax/servlet/jsp/el/VariableResolver Any ideas? From: Mark Lowe [mailto:[EMAIL PROTECTED] Sent: Mon 20/09/2004 2:56 PM To: Struts Users Mailing List Subject: Re: set not working % java.lang.String a = init; request.setAttribute(a,a); % c:out value=${a} / or c:set var=a value=init / c:out value=${a} / Mark On 20 Sep 2004, at 20:16, Anna Kerekes wrote: Hello, I am having some problems running the program below (it does not run the way it should). *The output I get is*** before a a is null after a *The desired output is before a init after a I'm not sure why ${a} is evaluating to null instead of init. any help appreciated, Anna Program: %@ page contentType=text/html;charset=UTF-8 language=java % %@ page import=java.lang.String % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % HTML % String a = init; % html:text property=var value=%= String.valueOf(a) % /br c:out value=before a / c:out value=${a} default=a is null/ c:out value=after a / /HTML - 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] - 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: No Way to Put the init() Method Inside the ActionForward Execute( ... ) Method
Why can't you call the init() method from inside the execute() method (at the beginning of it )? Anna From: Caroline Jen [mailto:[EMAIL PROTECTED] Sent: Fri 17/09/2004 2:06 PM To: [EMAIL PROTECTED] Subject: No Way to Put the init() Method Inside the ActionForward Execute( ... ) Method We cannot put a method inside another method. When using the Struts, we start with: public final class MyClass extends Action { public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws java.lang.Exception { ... ... } } I have a void init( ...) { ... } method shown below. Of course, I cannot put this init( ... ) inside the ActionForward Execute( ... ) { ... } What am I supposed to do? Do I put this void init( ... ) { ... } method before the ActionForward Execute( ... ) { ... } begins? Code: = String smtpServer; public void init(ServletConfig config) throws ServletException { super.init(config); smtpServer = config.getInitParameter(smtpServer); } = __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail - 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]
HTTPServletRequest object
Hello, I'm assuming that a request object is the same for a jsp and the associated Action Class. Why is it that when I try to get a parameter in the jsp I get the correct (expected) value: out.println(Message id from request(parameter): '+request.getParameter(messageId)+'); But when I try to get the same parameter, in the same way, from the corresponding Action Class, the parameter value is null. The jsp is basically just an input form, and the Action class processes the information retrieved. I'm not sure what I'm doing wrong, I've tried to look at the action-mappings-element in struts-config.xml but the scope is correctly set to request. Any help would be appreciated, Anna Kerekes - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CustomActionForward -- How do I pick it up in the Action?
thanks...problem solved. The request object is not the same in the action and the jsp! Anna Kerekes From: David G. Friedman [mailto:[EMAIL PROTECTED] Sent: Wed 15/09/2004 3:58 PM To: Struts Users Mailing List Subject: RE: CustomActionForward -- How do I pick it up in the Action? Doesn't your Action's nested forward need the attribute classname=SOMETHING ? Regards, David -Original Message- From: John Crossman [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 15, 2004 3:47 PM To: Struts Users Mailing List Subject: CustomActionForward -- How do I pick it up in the Action? My struts-config has the following: global-forwards type=cnwk.camaro.CustomActionForward forward name=DateFormat path=/do/Date/SampleView set-property property=commands value=stuff / /forward /global-forwards action-mappings action path=/Date/SampleView type=cnwk.camaro.MasterAction scope=request forward name=success path=/WEB-INF/pages/SampleView.jsp / /action /action-mappings And yet the following causes ClassCastException in my MasterAction class: CustomActionForward customForward = (CustomActionForward) mapping.findForward( DEFAULT_VIEW_KEY ); - 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]