Struts Spring Security
I'm trying to get Spring Security 3.0 working with a Struts 2.0.18 web-app that uses the Convention plugin using a customised login form. So far I've got form-login login-page=/login default-target-url=/startup always-use-default-target=false authentication-failure-url=/login?authfailed=true / access-denied-handler error-page=/login?notauthorized=true/ logout / login and startup are Struts actions and work fine for the login-page, default-target-url and authentication-failure-url tags, but when called through the access-denied-handler I get an Apache-Tomcat 404 error - so it's not even making it into Struts! This is an error that I particularly want to catch and log. Has anyone managed to get the access-denied-handler to cope with a Struts action? Regards -- View this message in context: http://old.nabble.com/Struts---Spring-Security-tp28409361p28409361.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 and dynamics web page
This example proved helpful to me: http://struts2inaction.com/SimpleAjax.html In the end I ended up doing the same with jQuery: s:select ... onchange= $('#divIDthatWillGetChanged').load('some.action?' + params ); / You can get the selected option and pass as params to the called action. The action has a result that is a jsp with just the content that will get loaded into the div (like a select). Em 30-04-2010 05:02, Stephane Cosmeur escreveu: Hello Struts 2 Users, I would like to call an action when an envent onchange from a s:select component is dispatched. According to the selected value I would like to load data in a form in order to modify it after. To do that i would like to call a Struts 2 action with AJAX, is it posible and is it the best solution to perofrm it ? In the JSP what should i do ? Case 1: the action return a jsp page inside the main jsp page s:select @include page=form.jsp Case 2 : the AJAX request refresh div by calling an action s:select div Any help would be greatly appreciated - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Error in running juit test case for struts2 action class
Hi, I am getting error when i am running my junit test case for struts2 action class. Here is the code. public class RoleMasterNewActionTest extends StrutsTestCase { public void setUp() throws Exception { super.setUp(); ObjectFactory.setObjectFactory( new ObjectFactory() ); } public void testDoSomeThing()throws Exception { RoleMasterNewAction action = new RoleMasterNewAction(); assertTrue(action.doSomeThing()); } } I am getting error at testDoSomeThing(). the error is -- 2010-04-30 15:07:12,263 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml] 2010-04-30 15:07:12,325 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml] 2010-04-30 15:07:12,388 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml] 2010-04-30 15:07:12,388 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form 2010-04-30 15:07:12,419 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration... 2010-04-30 15:07:12,419 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener -- but already i have the listener configuration in my web.xml. Thanks in advance.. -- View this message in context: http://old.nabble.com/Error-in-running-juit-test-case-for-struts2-action-class-tp28410616p28410616.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Building Menu's in Struts Applications
What tools/techniques are people using these days to build menus for their struts applications, particularly where menu/sub-menu contents are dynamic? Is the struts-menu project still active/relevant or is everyone rolling their own? How about Jquery and Json? I'm about to start a new greenfield project so I thought I'd check out to see what people are using these days. Regards -- View this message in context: http://old.nabble.com/Building-Menu%27s-in-Struts-Applications-tp28410774p28410774.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
ConcurrentModificationException error.
Hi We are struggling with this error in our application. We are on Struts 2.0.6 and Xworks version is 2.0.1. This issue is very intermittent but the best way we've been able to reproduce it is when we load the same page from two different browser windows or on two different machines. The stack trace looks like this: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372) at java.util.AbstractList$Itr.next(AbstractList.java:343) at com.opensymphony.xwork2.util.LocalizedTextUtil.findDefaultText(LocalizedTextUtil.java:174) at com.opensymphony.xwork2.util.LocalizedTextUtil.getDefaultMessage(LocalizedTextUtil.java:571) at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:449) at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:224) at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:99) at org.apache.struts2.components.Text.end(Text.java:158) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43) I initially thought that it had something to do with s:iterator tag but we are getting this error on pages where we are not even using an iterator. We are also getting it on somepages that DO use iterator. Since LocalizedTextUtil is involved...I am thinking that it has something to do with s:text. We use s:text to get the label name in our JSP. Does that go to LocalizedTextUtil? On this page (one without iterator) I am not doing anything that involves iterating over a list. At most what I see is the following code: s:select label=pType id=pType name=pType list = #...@java.util.linkedhashmap@{'ALL':'All Programs', 'P':'Public', 'S':'Private'} value=selectedP required=true/ Now LinkedHashMap is NOT synchronized...so if I load this at the same time...is it possible that it would give ConcurrentModificationException? or am i thinking along wrong lines since the log has no mention of this? I am really out of ideas with this one and would appreciate any input from you guys. Thanks
Re: Struts2 annotations and superclass
Ok...i think I found the solution. The super class can provide annotations at the method level for multiple subclasses using the @Actions. If a subclass needs to add or diverge from common functionality provided by superclass method, they can override the method, however, the subclasses method will have to provide the annotation since annotations are not inherited. /robert - Original Message - From: Robert Taylor rtay...@dtgresults.com To: Struts Users Mailing List user@struts.apache.org Sent: Wednesday, April 21, 2010 8:44 AM Subject: Struts2 annotations and superclass Greetings, We are converting from using Struts1 and XDoclet to Struts2 and Struts2 annotations. We have a base action class which handles requests which displays grid style information. The super class is a template pattern which does a lot of the common heavy lifting and exposes a method display which is invoked by a name specified in the action configuration for the url. Subclasses simply implement a method to retrieve a collection of objects. What we have been doing is placing the XDoclet annotations in the subclasses which specified the url and the method to invoke. With Struts2, I don't see that this is possible using just the annotations. It appears subclasses will have to override the superclass method just to bind a url. I don't see that the @Action annotation supports a method parameter or it may be possible. The same problem will occur for our CRUD action super classes. The subclasses will have to override the super class methods just to bind the method name to the url. So, am I missing something? Is it possible to use Struts2 annotations such that subclasses don't have to override super class methods simply to bind the method name to the url? /robert - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Where is the documentation for Struts tags ....
Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag which I still haven't been able to get working. Earlier today, I started trying to get the checkboxlist tag to work with a mapString,String and I'm still failing miserably. In both cases I get the infamous tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] style of error message when I fire up my action. Googling suggest that from the number of recent posts on StackOverflow and Java Ranch for example, I'm not the only one frustrated with this. When the struts tag reference page for checkboxlist gives as its only example s:checkboxlist name=foo list=bar/ and neither pages give any indication on how these tags interact with the action code, I begin to feel that this is all starting to be more trouble than it's worth. Someone, somewhere must know of a url where this is all explained with crystal clarity with useful code examples - I just can't find it at the moment. Yours in desperation -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28413026.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
Could you post the Action code and JSP tanks! SALUDOS!! Mario HIDALGO Java EE Consultant | Risk IT ___ Phone 1. (722) 277 ext. 783042 Phone 2. (55) 5721 opción 3 , ext. 783042 Mobile. 0447223547727 Email. mario.hida...@hsbc.com.mx Internet.HSBC México ___ RogerV roger.var...@googlemail.com 30 Apr 2010 09:43 AM Mail Size: 7136 Please respond to Struts Users Mailing List user@struts.apache.org To user@struts.apache.org cc Subject Where is the documentation for Struts tags Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag which I still haven't been able to get working. Earlier today, I started trying to get the checkboxlist tag to work with a mapString,String and I'm still failing miserably. In both cases I get the infamous tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} tag 'checkboxlist', field 'list', name 'roles': The requested list key 'availableroles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location] style of error message when I fire up my action. Googling suggest that from the number of recent posts on StackOverflow and Java Ranch for example, I'm not the only one frustrated with this. When the struts tag reference page for checkboxlist gives as its only example s:checkboxlist name=foo list=bar/ and neither pages give any indication on how these tags interact with the action code, I begin to feel that this is all starting to be more trouble than it's worth. Someone, somewhere must know of a url where this is all explained with crystal clarity with useful code examples - I just can't find it at the moment. Yours in desperation -- View this message in context: http://old.nabble.com/Where-is-the-documentation-for-Struts-tags--tp28413026p28413026.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable. No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author, and unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC group. “Este correo electrónico puede contener información confidencial, sólo está dirigida al destinatario del mismo, la información puede ser privilegiada. Está prohibido que cualquier persona distinta al destinatario copie o distribuya este correo. Si usted no es el destinatario, por favor notifíque esto de inmediato y destruya el correo, lo mismo que todas las copias que existan del mismo. Los correos electrónicos en internet, no son privados, seguros ni confiables. Ningún miembro del Grupo HSBC será responsable de los errores u omisiones en el contenido o transmisión de este correo electrónico. Cualquier opinión contenida en este correo es responsabilidad única y exclusiva del autor del mismo y, a menos que lo contrario se indique claramente y por escrito, no está respaldado por ningún miembro del Grupo HSBC”. This email may contain confidential information, and is intended only for the named recipient and may be privileged. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named recipient, please notify us immediately and permanently destroy this email and all copies of it. Internet email is not private, secure, or reliable. No member of the HSBC Group is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author, and unless clearly indicated otherwise in writing, are not endorsed by any member of the HSBC group. “Este correo electrónico puede contener información confidencial, sólo está dirigida al destinatario del mismo, la información puede ser privilegiada. Está prohibido que cualquier persona distinta al destinatario copie o distribuya este correo. Si usted no es el destinatario, por favor notifíque esto de inmediato y destruya el correo, lo mismo que todas las
Re: Building Menu's in Struts Applications
On 4/30/10 6:31 AM, RogerV wrote: What tools/techniques are people using these days to build menus for their struts applications, particularly where menu/sub-menu contents are dynamic? Is the struts-menu project still active/relevant or is everyone rolling their own? How about Jquery and Json? I'm still using struts-menu, but there's no magic. It's really just a way to go from an xml document describing the menus to a velocity template that determines how to render them. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
On 4/30/10 10:43 AM, RogerV wrote: Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag http://struts.apache.org/2.x/docs/optiontransferselect.html But there appears to be a bug with the snippets right now... ...so instead look at http://struts.apache.org/2.1.8/docs/optiontransferselect.html Usually the error message you listed means the OGNL expression you provided for some argument did not evaluate correctly, thus some required piece of information is not available. Please post your tag usage again and I'll take a look. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Error in running juit test case for struts2 action class
Short story, use StrutsSpringTestCase (from the junit plugin) instead of the StrutsTestCase. Long story - your unit tests aren't running inside of the web-app context. The web.xml listener configuration instantiates the applicationContext and puts it in the application scope where other spring components know where to find it. Since a unit test runs in the unit test context, it's not going to find the application context where it expects to. The StrutsSpringTestCase adds some extra bootstrap plumbing to make it work. -Wes On Fri, Apr 30, 2010 at 6:07 AM, rameshbabu rameshbab...@interlaceindia.com wrote: Hi, I am getting error when i am running my junit test case for struts2 action class. Here is the code. public class RoleMasterNewActionTest extends StrutsTestCase { public void setUp() throws Exception { super.setUp(); ObjectFactory.setObjectFactory( new ObjectFactory() ); } public void testDoSomeThing()throws Exception { RoleMasterNewAction action = new RoleMasterNewAction(); assertTrue(action.doSomeThing()); } } I am getting error at testDoSomeThing(). the error is -- 2010-04-30 15:07:12,263 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml] 2010-04-30 15:07:12,325 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml] 2010-04-30 15:07:12,388 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml] 2010-04-30 15:07:12,388 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert 2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form 2010-04-30 15:07:12,419 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration... 2010-04-30 15:07:12,419 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener
Re: ConcurrentModificationException error.
Do you have devMode set to true? Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Where is the documentation for Struts tags ....
http://struts.apache.org/2.0.14/docs/tag-reference.html On Fri, Apr 30, 2010 at 8:29 AM, Dale Newfield d...@newfield.org wrote: On 4/30/10 10:43 AM, RogerV wrote: Where is the latest documentation for using Struts 2 tags? I had a problem earlier in the week trying to use the optiontransferselect tag http://struts.apache.org/2.x/docs/optiontransferselect.html But there appears to be a bug with the snippets right now... ...so instead look at http://struts.apache.org/2.1.8/docs/optiontransferselect.html Usually the error message you listed means the OGNL expression you provided for some argument did not evaluate correctly, thus some required piece of information is not available. Please post your tag usage again and I'll take a look. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: ConcurrentModificationException error.
Are you using Iterator#remove() when iterating through a collection? On Fri, Apr 30, 2010 at 10:23 AM, Lukasz Lenart lukasz.len...@googlemail.com wrote: Do you have devMode set to true? Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Validate without submit?
Is it possible to fire the struts 2 validation without performing a submit? I realize that this could be done via ajax, but I am already committed to use another JS framework (not dojo, dwr or prototype) . I'd like to fire the validation and get the form validation messages back if any to be displayed on the page, as happens when the validation is fired from a submit -- but without performing the submit... Possible? Stupid question? Can it be done with jquery? Thank you in advance to any reply. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
Of course it can be done with JQuery and I recommend using JSON too. You call the action via Ajax and you get the JSON result and display it. Cimballi On Fri, Apr 30, 2010 at 1:36 PM, Ozu Natsu ozu.na...@gmail.com wrote: Is it possible to fire the struts 2 validation without performing a submit? I realize that this could be done via ajax, but I am already committed to use another JS framework (not dojo, dwr or prototype) . I'd like to fire the validation and get the form validation messages back if any to be displayed on the page, as happens when the validation is fired from a submit -- but without performing the submit... Possible? Stupid question? Can it be done with jquery? Thank you in advance to any reply. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
I am having some problems with the call, the ajax get returns no response, even though I know the form validation should be failing. My ajax call looks like this: var url= ./checkValid.do; $.ajax({ type: GET, cache : false, dataType: json, url url, data: $(this).serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true', success: function(data, textStatus, XMLHttpRequest) { // do something here alert(textStatus); } }); My action looks like this: action name=checkValid class=actionclass result type=json param name=rootjsonData/param /result /action Am I missing something? On Fri, Apr 30, 2010 at 1:59 PM, Cimballi cimballi.cimba...@gmail.com wrote: Of course it can be done with JQuery and I recommend using JSON too. You call the action via Ajax and you get the JSON result and display it. Cimballi On Fri, Apr 30, 2010 at 1:36 PM, Ozu Natsu ozu.na...@gmail.com wrote: Is it possible to fire the struts 2 validation without performing a submit? I realize that this could be done via ajax, but I am already committed to use another JS framework (not dojo, dwr or prototype) . I'd like to fire the validation and get the form validation messages back if any to be displayed on the page, as happens when the validation is fired from a submit -- but without performing the submit... Possible? Stupid question? Can it be done with jquery? Thank you in advance to any reply. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
I have something like that in the page : $.getJSON(..., function(json) { if (json.result == OK) { ... } else { ... } }); And in the action I have this : public String getResult() { return this.result; } In my case it's a single String but I suppose you can return more complex objects. Cimballi On Fri, Apr 30, 2010 at 2:51 PM, Ozu Natsu ozu.na...@gmail.com wrote: I am having some problems with the call, the ajax get returns no response, even though I know the form validation should be failing. My ajax call looks like this: var url= ./checkValid.do; $.ajax({ type : GET, cache : false, dataType: json, url url, data : $(this).serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true', success: function(data, textStatus, XMLHttpRequest) { // do something here alert(textStatus); } }); My action looks like this: action name=checkValid class=actionclass result type=json param name=rootjsonData/param /result /action Am I missing something? -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. On Fri, Apr 30, 2010 at 3:07 PM, Cimballi cimba...@cimballi.net wrote: I have something like that in the page : $.getJSON(..., function(json) { if (json.result == OK) { ... } else { ... } }); And in the action I have this : public String getResult() { return this.result; } In my case it's a single String but I suppose you can return more complex objects. Cimballi On Fri, Apr 30, 2010 at 2:51 PM, Ozu Natsu ozu.na...@gmail.com wrote: I am having some problems with the call, the ajax get returns no response, even though I know the form validation should be failing. My ajax call looks like this: var url= ./checkValid.do; $.ajax({ type : GET, cache : false, dataType: json, url url, data : $(this).serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true', success: function(data, textStatus, XMLHttpRequest) { // do something here alert(textStatus); } }); My action looks like this: action name=checkValid class=actionclass result type=json param name=rootjsonData/param /result /action Am I missing something? -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
1 step closer. I had missed the reference to the interceptor interceptor-ref name=jsonValidationWorkflowStack/ in my struts action. I am now getting a result back from the validator, but it doesn't seem to be firing my callback method. Can anyone help with this problem? Thank you! On Fri, Apr 30, 2010 at 3:45 PM, Cimballi cimba...@cimballi.net wrote: Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
Did you try with the getJSON method of JQuery ? Cimballi On Fri, Apr 30, 2010 at 5:01 PM, Ozu Natsu ozu.na...@gmail.com wrote: 1 step closer. I had missed the reference to the interceptor interceptor-ref name=jsonValidationWorkflowStack/ in my struts action. I am now getting a result back from the validator, but it doesn't seem to be firing my callback method. Can anyone help with this problem? Thank you! On Fri, Apr 30, 2010 at 3:45 PM, Cimballi cimba...@cimballi.net wrote: Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
var url= ./checkValid.do; var data= $('#update').serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true'; $.getJSON( url, data, function(data, textStatus) { // Do something alert(textStatus); }); The callback defined as function(data, textStatus){...} never gets invoked. Same with the call to the ajax get. I simply see the get request in the FireFox console with the reply. On Fri, Apr 30, 2010 at 5:05 PM, Cimballi cimba...@cimballi.net wrote: Did you try with the getJSON method of JQuery ? Cimballi On Fri, Apr 30, 2010 at 5:01 PM, Ozu Natsu ozu.na...@gmail.com wrote: 1 step closer. I had missed the reference to the interceptor interceptor-ref name=jsonValidationWorkflowStack/ in my struts action. I am now getting a result back from the validator, but it doesn't seem to be firing my callback method. Can anyone help with this problem? Thank you! On Fri, Apr 30, 2010 at 3:45 PM, Cimballi cimba...@cimballi.net wrote: Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
I noticed that I am not using the json interceptor, only the result : result-type name=json class=org.apache.struts2.json.JSONResult / What are you using ? Cimballi On Fri, Apr 30, 2010 at 5:16 PM, Ozu Natsu ozu.na...@gmail.com wrote: var url= ./checkValid.do; var data= $('#update').serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true'; $.getJSON( url, data, function(data, textStatus) { // Do something alert(textStatus); }); The callback defined as function(data, textStatus){...} never gets invoked. Same with the call to the ajax get. I simply see the get request in the FireFox console with the reply. On Fri, Apr 30, 2010 at 5:05 PM, Cimballi cimba...@cimballi.net wrote: Did you try with the getJSON method of JQuery ? Cimballi On Fri, Apr 30, 2010 at 5:01 PM, Ozu Natsu ozu.na...@gmail.com wrote: 1 step closer. I had missed the reference to the interceptor interceptor-ref name=jsonValidationWorkflowStack/ in my struts action. I am now getting a result back from the validator, but it doesn't seem to be firing my callback method. Can anyone help with this problem? Thank you! On Fri, Apr 30, 2010 at 3:45 PM, Cimballi cimba...@cimballi.net wrote: Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
I've tried both json result type and what the docs use: http://struts.apache.org/2.0.14/docs/ajax-validation.html. No luck. I just added an onComplete event handler and I see that i am getting textStatus passed as parseError.??? So the success event handler is not being called because of some error. I'm not sure how to figure out what error it is. Anyone have any ideas? On Fri, Apr 30, 2010 at 5:36 PM, Cimballi cimba...@cimballi.net wrote: I noticed that I am not using the json interceptor, only the result : result-type name=json class=org.apache.struts2.json.JSONResult / What are you using ? Cimballi On Fri, Apr 30, 2010 at 5:16 PM, Ozu Natsu ozu.na...@gmail.com wrote: var url= ./checkValid.do; var data= $('#update').serialize()+'struts.enableJSONValidation=truestruts.validateOnly=true'; $.getJSON( url, data, function(data, textStatus) { // Do something alert(textStatus); }); The callback defined as function(data, textStatus){...} never gets invoked. Same with the call to the ajax get. I simply see the get request in the FireFox console with the reply. On Fri, Apr 30, 2010 at 5:05 PM, Cimballi cimba...@cimballi.net wrote: Did you try with the getJSON method of JQuery ? Cimballi On Fri, Apr 30, 2010 at 5:01 PM, Ozu Natsu ozu.na...@gmail.com wrote: 1 step closer. I had missed the reference to the interceptor interceptor-ref name=jsonValidationWorkflowStack/ in my struts action. I am now getting a result back from the validator, but it doesn't seem to be firing my callback method. Can anyone help with this problem? Thank you! On Fri, Apr 30, 2010 at 3:45 PM, Cimballi cimba...@cimballi.net wrote: Ozu, nut sure to be able to help you more. I know how to call an action in Ajax, now it seems you want to reproduce Struts2 validation process using Ajax and this requires more analysis. What you can do at least is do the validation in you main action method. And even better, I think you could even specify the name of the method to call in your action. Another option is to create 2 actiosns in your configuration file calling the same java action, one for the real action, and the other for the validation. Cimballi On Fri, Apr 30, 2010 at 3:34 PM, Ozu Natsu ozu.na...@gmail.com wrote: Closer, still not working... I had 2 problems (I think). #(this).serialize() was not serializing the form data. I put my form name in for the selector and now the form data is being passed to the get. I think the other problem is that the action method doesn't match my validator name. My validator is set up as Action-update-validation.xml. So I added method =update to the struts action definition. Now it appears to be trying to peform the update instead of just performing the validation. What exactly should be the chain of events happening here? Shouldn't it be something like the get invokes the validate() method, which returns json data to the javascript callback where my alert is at? I would have suspected my callback method data to be populated with the validation results. -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ -- Cimballi JAVA J2EE Freelance http://cimballi.elance.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
On 4/30/10 6:50 PM, Ozu Natsu wrote: Anyone have any ideas? Debugging from the client side: Firebug in Firefox. Debugging from the server side: log messages (log4j or other). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts2 - Ajax submit not working: Please advise
Hi All, I am experiencing some issues with ajax submit with Struts2. I am trying to do an asynchronous post to an action class that will make a crud call and return back the html page with the updated input value. I am able to get the result when posting to form action without using ajax. %@ taglib prefix=s uri=/struts-tags% %@ taglib prefix=sx uri=/struts-dojo-tags % html xmlns=http://www.w3.org/1999/xhtml; head s:head theme=ajax debug=true/ /head body s:div id=updateDiv theme=ajax s:text name=Welcome : / s:property value=#session['auth'].fullName / table trtds:actionerror/s:fielderror //td/tr s:form name=updateStatus action=action_item_update validate=true tr tds:select name=actionStatus headerKey= headerValue=Change Status list=statuses / /td tds:hidden name=id //td td s:submit theme=ajax name=update value=Update notifyTopics=/action_item_update targets=updateDiv/ /td /tr /s:form /table /s:div /body /html When I remove all ajax related attributes from s:submit / tag, then the application is submitted without any issues, but not when using Ajax submission. On my form, I see the following: Action Item List DEBUG: widget ID collision on ID: action_item_update_update On submission, I see the following error: Action Item List [object Error] DEBUG: widget ID collision on ID: action_item_update_update Action Item List DEBUG: widget ID collision on ID: updateDiv The form parameters are always null on ajax submit. Can anyone tell me what I am doing wrong? Any help would be appreciated.
Re: Validate without submit?
Dale, So close! I am now to the point where I am getting the errors, but when I try to use the struts utilities to display them, I am getting an undefined object in the struts validation.js function addErrorXHTML(e, errorText) ; My code looks like this: complete : function(XMLHttpRequest, textStatus){ var form= $('#update')[0]; //clear previous validation errors, if any StrutsUtils.clearValidationErrors(form); //get errors from response var text = XMLHttpRequest.responseText; var errorsObject = StrutsUtils.getValidationErrors(text); //show errors, if any if(errorsObject.fieldErrors) { StrutsUtils.showValidationErrors(form, errorsObject); } } On Fri, Apr 30, 2010 at 5:55 PM, Dale Newfield d...@newfield.org wrote: On 4/30/10 6:50 PM, Ozu Natsu wrote: Anyone have any ideas? Debugging from the client side: Firebug in Firefox. Debugging from the server side: log messages (log4j or other). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
The problem looks as if it is in the DOM, I'm wondering if this isn't jquery's fault? All of the field names in the form.elements are somehow mangled. artNumber instead of partNumber On Fri, Apr 30, 2010 at 6:14 PM, Ozu Natsu ozu.na...@gmail.com wrote: Dale, So close! I am now to the point where I am getting the errors, but when I try to use the struts utilities to display them, I am getting an undefined object in the struts validation.js function addErrorXHTML(e, errorText) ; My code looks like this: complete : function(XMLHttpRequest, textStatus){ var form= $('#update')[0]; //clear previous validation errors, if any StrutsUtils.clearValidationErrors(form); //get errors from response var text = XMLHttpRequest.responseText; var errorsObject = StrutsUtils.getValidationErrors(text); //show errors, if any if(errorsObject.fieldErrors) { StrutsUtils.showValidationErrors(form, errorsObject); } } On Fri, Apr 30, 2010 at 5:55 PM, Dale Newfield d...@newfield.org wrote: On 4/30/10 6:50 PM, Ozu Natsu wrote: Anyone have any ideas? Debugging from the client side: Firebug in Firefox. Debugging from the server side: log messages (log4j or other). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Validate without submit?
Arg! Something else is going on. Maybe related to the parseError? I am assuming the callback should be on the success function, not the error/complete. I replaced the jquery $('update')[0] reference with document.forms[0] and I get the exact same thing. Moreover, it looks as if the errorsObect.fieldErrors has ALL my validations in it, regardless of whether the field had a value or not. On Fri, Apr 30, 2010 at 6:20 PM, Ozu Natsu ozu.na...@gmail.com wrote: The problem looks as if it is in the DOM, I'm wondering if this isn't jquery's fault? All of the field names in the form.elements are somehow mangled. artNumber instead of partNumber On Fri, Apr 30, 2010 at 6:14 PM, Ozu Natsu ozu.na...@gmail.com wrote: Dale, So close! I am now to the point where I am getting the errors, but when I try to use the struts utilities to display them, I am getting an undefined object in the struts validation.js function addErrorXHTML(e, errorText) ; My code looks like this: complete : function(XMLHttpRequest, textStatus){ var form= $('#update')[0]; //clear previous validation errors, if any StrutsUtils.clearValidationErrors(form); //get errors from response var text = XMLHttpRequest.responseText; var errorsObject = StrutsUtils.getValidationErrors(text); //show errors, if any if(errorsObject.fieldErrors) { StrutsUtils.showValidationErrors(form, errorsObject); } } On Fri, Apr 30, 2010 at 5:55 PM, Dale Newfield d...@newfield.org wrote: On 4/30/10 6:50 PM, Ozu Natsu wrote: Anyone have any ideas? Debugging from the client side: Firebug in Firefox. Debugging from the server side: log messages (log4j or other). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org