Struts ActionForms and DWR/AJAX
I am thinking about migrating an application using Struts and ActionForms to use the DWR implementation of AJAX. I stood up a simple DWR sample and I'm realizing that it may not be possible to integrate DWR with ActionForms -- DWR makes requests through the backdoor (ie, XMLHttpRequest), rather than by submitting a form created by html:form, so the Struts ActionForm does not get populated. In fact, request.getParameterNames() returns an 0-element enumeration, which makes me think it may not be possible at all. Does anyone have experience with ActionForms and AJAX? I did a quick Google search and found this article: http://getahead.ltd.uk/dwr/server/struts Any help would be appreciated. Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: RE: how to represent nested bean properties in a jsp form
Temp temp, I'll need some more information from you before I can be much help. Is the Form class (ServiceSelectionForm) being invoked properly? Are non-nested elements being populated correctly? Are you getting any errors? -Greg -Original Message- From: temp temp [mailto:[EMAIL PROTECTED] Sent: Thursday, September 08, 2005 10:54 AM To: user@struts.apache.org Subject: Fwd: RE: how to represent nested bean properties in a jsp form No I have no problem with property NEWSEARCH . I want to know how can my jsp represent nested property state (property from AddressVO ) ? thanks regards __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Populating Form objects without Struts?
In previous projects where I have used ActionForms, I have always used Struts.I am currently working on a project that, for various reasons, does not use Struts. Is there a way to harvest the advantages of ActionForms without Struts? In particular, I have a form that the user fills out with checkboxes and a comments section. There are many of them: the business logic dictates that the form contain 3 zones. Each zone has between 4 and 10 questions. Each question has a checkbox and a comment field. Ideally I would create a bean with a series of Zone objects which contain Question objects which each contain a boolean checked and a String comment--problem solved. However, I haven't ever done this without Struts, so I don't know of any way to have the values populated in an Object sent with the form submission--the action servlet usually takes care of that. Is there a tool for doing this or any suggested workaround without Struts? Sorry if I'm missing something completely obvious: a quick scan of previous posts and the LazyList and BeanUtils APIs didn't make any lights go on. Thanks, Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sending value from popup to parent window
Fez, Perhaps I am missing something simple, but couldn't your sendValue() function just get the .selectedIndex of the multiBox, then you can iterate through the select's options and get the one your need? This seems to be more a question of some JS engineering, at least that is the simplest way in my mind. I haven't used html:multibox, though, so it could be more complicated. HTH, Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, June 13, 2005 7:39 AM To: user@struts.apache.org Subject: RE: Sending value from popup to parent window Has anybody any advice on this at all...? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 13 June 2005 11:33 To: user@struts.apache.org Subject: Sending value from popup to parent window Hi, I am a bit stuck on implementing the following so all help is appreciated. I open up a search page as a pop up window. The user implements the search options and is returned a number of rows. The user then selects one of these rows using a check box which I have defined as a multibox in my jsp. The problem I have is populating the field on the parent window with the value of the multibox? In the JSP i define my multibox as such html:multibox name=actionClientForm property=resourceIds bean:write name=client property=resourceId/ /html:multibox The link to close this page and send the value is as follows: td align=right html:link href=javascript:sendValue();Add Client/html:link /td The javascript function: script language=JavaScript function sendValue(s) { var selvalue = s out.println(variable = + selvalue); window.opener.document.createClnForm.clientId.value = selvalue; window.close(); } /script If I put a value of 1 in the link where i call the javascript it works fine and puts 1 into the correct field on the parent window. td align=right html:link href=javascript:sendValue(1);Add Client/html:link /td However what i want to send back is the bean:write name=client property=resourceId/ of the selected multibox. i tried using bean define but that did not seem to work. The property resourceIds of the actionClientForm is a collection. Anyone know how to do this? thanks fez - 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 can we send parameter's value to javascript function ??
You can't mix %= % and struts form elements (eg, html:radio). Your best bet is to change the javascript to whichAuctionType(this)--send the input element--then inside your JS function, get the value by doing a .value on the element passed in. -Original Message- From: minhnguyet [mailto:[EMAIL PROTECTED] Sent: Friday, May 20, 2005 8:47 PM To: user@struts.apache.org Subject: How can we send parameter's value to javascript function ?? Hi all, I want to send parameter 's value to javascript function . When I use html : radio as follow html:radio property=auctionTypeId value=%=(String)rId% onclick='javascript:whichAuctionType(%=(String)rId%);'/ , the value is not send and this is a result in IE input type=radio name=auctionTypeId value=1 onclick=javascript:whichAuctionType(%=(String)rId%); But when use input type=radio as follow input type=radio name=auctionTypeId value=%= (String)rId% onclick='javascript:whichAuctionType(%=(String)rId%);'/ everything is work right : input type=radio name=auctionTypeId value=1 onclick='javascript:whichAuctionType(1);'/ . I don't see what is different in html code . So , how can we directly send parameter value to javascript using html:radio/ tag ? Thanks in advance ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Passing in key to bean:write or c:out at runtime
Is it possible to use bean:write / or c:out / to look up a key that is not known until runtime (ie, stored in the request)? I have a results screen that will display a message that varies depending on the query performed. I would like this message to be retrieved from the message-resources ../ bundle in the struts-config.xml. For example, my Action will have logic: if (isFriend) { request.setAttribute(friendText, key.friend); } else if (isEnemy) { request.setAttribute(friendText, key.enemy); } else { request.setAttribute(friendText, key.unknown); } I would like my JSP to get the value of the Request Attribute friendText, then lookup that key in the MessageResources file: key.friend = PHello friend. I like you. key.enemy = PHello enemy. I hate you. key.unknown = PHello. I checked the API for bean:write and c:out and looking to see if struts-el provided this functionality. I didn't see any indication that it does, though I have not used struts-el in the past. Any ideas? Thanks! Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to get form from JSP
The ActionForm is stored in the request with the same name as the form-bean's name. If you have a form bean: form-bean name=loginForm type = project.struts.form.LoginForm / You can get the form in the JSP like this: % project.struts.form.LoginForm myLoginForm = (project.struts.form.LoginForm) request.getAttibute(loginForm); % -Greg -Original Message- From: Wiebe de Jong [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 9:38 AM To: 'Struts Users Mailing List' Subject: RE: How to get form from JSP The form is already defined as a bean. You can access it using the name you gave it in your struts-config file. i.e. form-bean name=myForm ... Wiebe -Original Message- From: Billy Ng [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 9:16 AM To: Struts Users Mailing List Subject: How to get form from JSP Hi all, Is there a way to get the ActionForm obj in the JSP instead of using bean:define tag Thanks! Billy - 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: Validating an amount with commas allowed
Here's a better mask to use: var var-namemask/var-name var-value^\$?\d+(,\d{3})*(\.\d{2})?$/var-value /var This mask: --allows (but does not require) a leading dollar sign (if you want to remove this feature, get rid of the \$? at the beginning (but leave the ^) --allows (but does not require) a decimal point + 2 trailing digits. It requires: --each comma to have at least 1 digit before it (fails on ,500) --exactly three digits after each comma (fails on $1,00.00) Here's a tester you can put in your HTML: script var pattern = /^\$?\d+(,\d{3})*(\.\d{2})?$/; if (pattern.exec($1,500,200.99)) { alert ('matches'); } else { alert ('does not match'); } /script HTH, Greg -Original Message- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 06, 2005 3:39 PM To: Struts Users Mailing List Subject: Re: Validating an amount with commas allowed I'm useless with regex. However, I found this on the web some time ago and seemed to match what I needed back then: var var-namemask/var-name var-value^(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,2}){0,1}$/var-value /var This allows them to include the .00 if they so desire. hth, Hubert On Apr 6, 2005 5:08 PM, Wendy Smoak [EMAIL PROTECTED] wrote: I have a form with a required amount. The users like to enter things like $50k which thoroughly confuses the system that tries to send a different email if the amount is over or under $25,000. I think I can make them stop entering dollar signs and letters... but I don't think they'll part with the commas. Before I write a custom validator, am I missing something simple that would allow me to accept 40,000 as a valid amount? The only thing I see is integer validation, which is too strict. Thanks, -- 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Obtaining size of java.util.Collection through Struts/JSTL
What is the prefered way to obtain the size of elements that implement the Collection interface, such as a Vector? I would like something like: c:out value=${requestScope.myVector.size} default=/ elements exist in this Vector! But since the method is called size() and not getSize(), Struts can't handle it. Right now I am using scriptlets: % java.util.Vector v = request.getAttribute(myVector); % ...and later... P%= v.size() % elements exist in this Vector! Any advice? Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: focussing on image in jsp
Another approach would be to have the image be an input ../ tag. Then you could add an onload=document.form.element.focus() to your body tag. HTH, Greg -Original Message- From: Vilpesh Mistry [mailto:[EMAIL PROTECTED] Sent: Friday, March 25, 2005 5:38 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: focussing on image in jsp hi why not have a anchor near or above image and focus or move to that anchor thanks --- Raghuveer Vellanki [EMAIL PROTECTED] wrote: can any one provide information on , focussing on image in jsp when page loads. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 - 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: Validation - Mask
Add a ^ to the beginning of the pattern. Try changing: var-value[^/$amp;=]+$/var-value To var-value^[^/$amp;=]+$/var-value That should work. If you're not familiar with regular expressions, a ^ at the beginning of a regexp matches the string starting at the beginning (just as the $ matches at the end). Without it, as long as _something_ comes before the forbidden characters, the mask will return true. To see the difference, paste this Javascript into an HTML doc. script var pattern = /[^$]+$/; //this will match in the regular expression alert (pattern.exec(this is a Test)) ; var pattern = /^[^$]+$/; //regexp will fail. alert (pattern.exec(this is a Test)) ; /script Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Prepopulating Form elements in ActionForms
I am having trouble with the ActionForm reset() method. I am using the method to handle prepopulating form values. My Struts app uses the Struts Validator's DynaValidatorForm (which extends ActionForm via the DynaActionForm class). I am attempting the following behavior in a class I call BaseActionForm: 1. Prepopulate form values in the reset() method of BaseActionForm. 2. When the JSP is submitted, if no value has been populated for a variable named ptn (and if other criteria are true), return to the original JSP (via an action-mapping) and display an error message, plus show the form inputs the user entered (not the prepopulated defaults). The problem I run into is that the reset() method seems to be populating my DynaValidatorForm before the page is loaded and after as well. I want the reset() method called beforehand - this prepopulates my form values. However, when DynaValidatorForm.reset() is called after the form is submitted, it is re-prepopulating the submitted form with defaults, the result being that if the user erases a prepopulated value, the ActionForm repopulates it with the default. In other words, a value of foo was prepopulated, the user erases that value and submits, the form prepopulates it again with foo (bad!) and passes control to the action. I also want to make sure that if the form elements have been incorrectly populated, when the form returns to the JSP, it has not clobbered the user-supplied (albeit incorrect) empty form values. I have tried adding a check in the ActionForm (if super.get(ptn) is ), but it seems that this check always returns true from within the ActionForm's reset() method. It appears that the ActionServlet populates the form after it calls reset(). I have done the usual web searches but have not found any good resource that explains the proper way to use reset() or handle form prepopulation using Struts. I am aware that the reset() method is primarily intended for checkbox prepopulation (only), but I do not know of a better way to handle the above issue. I used this approach because it was recommended in Apress's Pro Jakarta Struts. Can anyone provide advice or point me to some code examples/resources (preferably using the DynaValidatorForm subclass of ActionForm, which retrieves form element values using super.get(), as shown above)? Thanks, Greg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: DynaActionForm
I think you have 2 errors in the HTML below 1. try changing action=/viewProjects to action=viewProjects (not sure if this is necessary) 2. you need to use html:hidden property=junk rather than an input -- html:form method=post action=/viewProjects input type=hidden name=junk value=junk/ /html:form -- Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 6:36 PM To: user@struts.apache.org Subject: DynaActionForm Hi folks, I am using a DynaActionForm with an Action. I have the following exception when the form is submitted. but if I use a regular ActionForm it's ok... what's wrong? thanks in advance my form-bean: form-bean name=emptyForm type=org.apache.struts.action.DynaActionForm form-property name=junk type=java.lang.String/form-property /form-bean my action-mapping: action path=/viewProjects name=emptyForm type=com.xxx.ViewProjectsAction forward name=success path=/calc/ProjectManager.jsp/ forward name=failure path=/calc/AssessmentCalc.jsp/ /action my form: html:form method=post action=/viewProjects input type=hidden name=junk value=junk/ /html:form SRVE0068E: Could not invoke the service() method on servlet action. Exception thrown : java.lang.NullPointerException at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:852) at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor .java:364) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:253) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code)) at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code)) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(C ompiled Code)) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper. java(Compiled Code)) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220) at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compile d Code)) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compi led Code)) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(Ht tpInboundLink.java(Compiled Code)) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(Ht tpInboundLink.java(Compiled Code)) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLRea dCallback.java(Compiled Code)) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManage r.java(Compiled Code)) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java (Compiled Code)) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java (Compiled Code)) at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.jav a(Compiled Code)) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code)) __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ - 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]