Re: validation and form display problem
what i did was to override ValidationAware.hasErrors(). according to the docs, the workflow interceptor calls this method, if there are validation errors, it returns "input" and stops further execution of the action. i tried this... public boolean hasErrors() { boolean result = super.hasErrors(); if(result) { //fetch data here } return result; } On Sun, Jul 11, 2010 at 7:23 AM, Burton Rhodes wrote: > That sounds like a classic 'prepare' problem. Take a look at the > documentation on implementing Preparable in your action. You will want > to initialize your backing beans inside the Prepare method in your > action. That when 'input' is needed, your backing beans will be > loaded. > > On 7/10/10, Jake Vang wrote: >> i have a form that i display. but to display that form, i have to >> fetch some data from the database and then place that data on the >> valuestack (via backing beans). when the form is displayed, it expects >> that those backing beans should be populated. the form then posts to a >> save action. >> >> i have a --validation.xml that validates the form >> values. i have specified that if the result is "input" then go back to >> the form. the problem is that when the result is "input" and the >> form/page is reloaded, the beans are no longer populated and the form >> displays as blank. >> >> is there a way to intercept or is there a hook that i can grab to have >> an opportunity to populate my backing beans? >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > -- > Sent from my mobile device > > - > 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: validation and form display problem
That sounds like a classic 'prepare' problem. Take a look at the documentation on implementing Preparable in your action. You will want to initialize your backing beans inside the Prepare method in your action. That when 'input' is needed, your backing beans will be loaded. On 7/10/10, Jake Vang wrote: > i have a form that i display. but to display that form, i have to > fetch some data from the database and then place that data on the > valuestack (via backing beans). when the form is displayed, it expects > that those backing beans should be populated. the form then posts to a > save action. > > i have a --validation.xml that validates the form > values. i have specified that if the result is "input" then go back to > the form. the problem is that when the result is "input" and the > form/page is reloaded, the beans are no longer populated and the form > displays as blank. > > is there a way to intercept or is there a hook that i can grab to have > an opportunity to populate my backing beans? > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Sent from my mobile device - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: validation and form display problem
you could use the org.apache.struts2.config_browser.ShowValidatorAction then use java.beans.Introspector to acquire the bean from Validator.class try { java.beans.BeanInfo beanInfoFrom = java.beans.Introspector.getBeanInfo(validator.getClass(), Object.class); } catch (IntrospectionException e) { LOG.error("An error occurred", e); addActionError("An error occurred while introspecting a validator of type " + validator.getClass().getName()); return ERROR; } //make sure you get back non null validator from getSelectedValidator() accessor public com.opensymphony.xwork2.validator.Validator getSelectedValidator() { return (com.opensymphony.xwork2.validator.Validator) validators.get(selected); } Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Sat, 10 Jul 2010 18:10:32 -0400 > Subject: validation and form display problem > From: vangj...@googlemail.com > To: user@struts.apache.org > > i have a form that i display. but to display that form, i have to > fetch some data from the database and then place that data on the > valuestack (via backing beans). when the form is displayed, it expects > that those backing beans should be populated. the form then posts to a > save action. > > i have a --validation.xml that validates the form > values. i have specified that if the result is "input" then go back to > the form. the problem is that when the result is "input" and the > form/page is reloaded, the beans are no longer populated and the form > displays as blank. > > is there a way to intercept or is there a hook that i can grab to have > an opportunity to populate my backing beans? > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
validation and form display problem
i have a form that i display. but to display that form, i have to fetch some data from the database and then place that data on the valuestack (via backing beans). when the form is displayed, it expects that those backing beans should be populated. the form then posts to a save action. i have a --validation.xml that validates the form values. i have specified that if the result is "input" then go back to the form. the problem is that when the result is "input" and the form/page is reloaded, the beans are no longer populated and the form displays as blank. is there a way to intercept or is there a hook that i can grab to have an opportunity to populate my backing beans? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org