Re: problem occured while validating form
I'm having a little trouble understanding the question. ji liu wrote: >when validating form,some problems occured. >As MVC Model2 suggest,I use a controller to query >imformations and store them into javabeans.Then the >javabeans is used by the page which contains a form. >when the form submits,the form is validated.If some >errors occured,struts will return to input page.As the >input page need some informations to render the >page,so I make the struts return to the controller >which queries information required by the input >page. > Right, a common problem with several solutions discussed frequently on this list. What specific strategy are you using (you only say "return to the controller")? Are you "chaining" actions by forwarding to a "setup" (form prepopulation) action from your POST-handling action? I think that you are, but I'm just trying to get you to be more specific. >some informations may be changed when the form >submitted,but the controller doesn't know this. > > Can you elaborate on this? I don't know what you mean by this. >How to solve this problem? >I use two controller.One is used when user requests >the page at the first time.Another is used when >validating errors occur. > > Can you be more specific about what you mean by "controller"? Do you mean ActionServlet instance? Sorry for misunderstanding. Erik >_ >Do You Yahoo!? >150万曲MP3疯狂搜,带您闯入音乐殿堂 >http://music.yisou.com/ >美女明星应有尽有,搜遍美图、艳图和酷图 >http://image.yisou.com >1G就是1000兆,雅虎电邮自助扩容! >http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ > >- >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: Specifying HTML form names
On Sun, 2004-08-15 at 00:19, Jacob Weber wrote: > I have a JSP with two forms, and they both need to go to the same > action. But Struts assumes that the "name" property of the HTML form > (e.g. ) should be the same as the name of the > associated form bean. As a result, I can't use JavaScript to refer to > one of the forms, since they both have the same name. > > Is this a situation where I need to write my own version of ? > Why does Struts make this assumption? > > Things I've already considered: > > - Using two different actions with different form beans. This doesn't > work, since the JSP needs to refer to the form bean by name (for > example, in ). If I use two actions that return the same > JSP, they need to use the same form bean. Why can't you do this? in MyAction.java String formName = mapping.getAttribute(); request.setAttribute("formName", formName); Struts.config.xml On the HTML/JSP page do all your bean writes according to the value of <% String name = request.getAttribute("formName"); foo.MyForm theForm = request.getAttribute(name); %> etc. etc. -- Matthew Van Horn <[EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read only iterate?
Refer: http://struts.apache.org/faqs/indexedprops.html > > > Problematic input > > property="integer_value" indexed="true"/> > > > Try the one below: Problematic input Thanks, Kishore Senji. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read only iterate?
On Friday 13 August 2004 09:40, Jim Barrows wrote: > > -Original Message- > > From: Mike Elliott [mailto:[EMAIL PROTECTED] > > Sent: Friday, August 13, 2004 9:33 AM > > To: [EMAIL PROTECTED] > > Subject: Read only iterate? > > > > > > I've been totally defeated in my attempt to alter an html:text > > element inside a logic:iterate tag. There must be a way to > > accomplish this, but I've been beating my head against the wall > > for three days now without making progress. > > > > I have simplified the problem substantially from the initial page. > > What I have now looks like this: > > from > http://struts.apache.org/userGuide/struts-html.html#text > I'm guessing that a List won't work and you need to have an array. No -- changing it to a list makes no difference whatsoever: package problem; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import java.util.ArrayList; import java.util.List; public class ProblemBean extends ActionForm { final private static int ENTRY_ROW_COUNT = 2; public ProblemBean() { log.info( "initializing entries" ); entries = new ArrayList(); // Create some entries for the form for (int ndx = 0 ; ndx < ENTRY_ROW_COUNT; ndx ++) { ProblemItem a = new ProblemItem(); a.setInteger_value( new Integer(ndx)); entries.add( a ); } } private String working_perfectly = "A Value"; public String getWorking_perfectly() { log.info( "getWorking_perfectly" ); return working_perfectly; } public void setWorking_perfectly( String working_perfectly ) { log.info( "setWorking_perfectly to '" + working_perfectly + "'"); this.working_perfectly = working_perfectly; } private List entries; public ProblemItem[] getEntries() { log.info( "getEntries" ); ProblemItem[] result = new ProblemItem[entries.size()]; for (int ndx = 0; ndx < entries.size(); ndx++) result[ndx] = (ProblemItem)entries.get( ndx ); return result; } public void setEntries( List entries ) { log.info( "setEntries" ); this.entries = entries; } public static class ProblemItem extends ActionForm { // Used so that each item can have a unique value. private static Integer incrementing = new Integer( 0 ); public ProblemItem() { this.integer_value = incrementing; incrementing = new Integer( incrementing.intValue() + 1 ); } private Integer integer_value; public Integer getInteger_value() { log.info( "getInteger_value" ); return integer_value; } public void setInteger_value( Integer iValue ) { log.info( "setInteger_value to " + iValue ); this.integer_value = iValue; } private static Logger log = Logger.getLogger( ProblemItem.class ); } private static Logger log = Logger.getLogger( ProblemBean.class ); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read only iterate?
On Friday 13 August 2004 09:43, Brian Lee wrote: > Lists work, but you have to write your own set(int index) method to set the > correct object from the List. > > BAL I still believe that lists work -- it's not lack of belief that's the problem, it's lack of results. There's some magic involved that, if documented anywhere is somewhere I have yet to uncover. Based on the general principal of orthogonality if the get method is properly invoked (which it apparently is) then the equivalent set method should also be invoked. That's simply not happening. However, orthogonality aside, if writing a separate indexed set method would make the problem go away I'd gladly use it. Alas, however, that doesn't make the slightest difference. I added two indexed set methods as you suggested with depressingly familiar results: package problem; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import java.util.ArrayList; import java.util.List; public class ProblemBean extends ActionForm { final private static int ENTRY_ROW_COUNT = 2; public ProblemBean() { log.info( "initializing entries" ); entries = new ArrayList(); // Create some entries for the form for (int ndx = 0 ; ndx < ENTRY_ROW_COUNT; ndx ++) { ProblemItem a = new ProblemItem(); a.setInteger_value( new Integer(ndx)); entries.add( a ); } } private String working_perfectly = "A Value"; public String getWorking_perfectly() { log.info( "getWorking_perfectly" ); return working_perfectly; } public void setWorking_perfectly( String working_perfectly ) { log.info( "setWorking_perfectly to '" + working_perfectly + "'"); this.working_perfectly = working_perfectly; } private List entries; public List getEntries() { log.info( "getEntries" ); return entries; } public void setEntries( List entries ) { log.info( "setEntries" ); this.entries = entries; } // Added an indexed setter "just in case" public void setInteger_value( int ndx, Integer iValue ) { log.info( "OHMYGOD -- IT GOT INVOKED!" ); ProblemItem pi = (ProblemItem)getEntries().get( ndx ); pi.setInteger_value( iValue ); } public static class ProblemItem extends ActionForm { // Used so that each item can have a unique value. private static Integer incrementing = new Integer( 0 ); public ProblemItem() { this.integer_value = incrementing; incrementing = new Integer( incrementing.intValue() + 1 ); } private Integer integer_value; public Integer getInteger_value() { log.info( "getInteger_value" ); return integer_value; } public void setInteger_value( Integer iValue ) { log.info( "setInteger_value to " + iValue ); this.integer_value = iValue; } // Added an indexed setter "just in case" public void setInteger_value( int ndx, Integer iValue ) { log.info( "OHMYGOD -- IT GOT INVOKED!"); this.integer_value = iValue; } private static Logger log = Logger.getLogger( ProblemItem.class ); } private static Logger log = Logger.getLogger( ProblemBean.class ); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Read only iterate?
On Friday 13 August 2004 09:40, Richard Yee wrote: > Mike, > What does the generated HTML look like? The generated HTML is not the problem; the failure to invoke the set method is the problem. However, maybe looking at it would provide some insight into the cause. Anyway, here it is: Problem page Problematic input Problematic input Functioning input - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts with Flex
Hi, Has anyone any experience with Struts and Flex (http://www.macromedia.com/software/flex/ , http://www.macromedia.com/devnet/flex/articles/struts.html) that would like to share ? How about Struts+XML+(XSLT/Flex) ? Regards, Ovidiu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Specifying HTML form names
IIRC, the form tag used to have an attribute so you can specify the form name, though I never used it because I never needed to. It was deprecated and eventually removed. Hubert --- Jacob Weber <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > There was only one entry for the two similarly named forms. Checking the > > fields of the form showed me that only the latest definition of a form > with a > > given name is recognized. > > > > So, you should probably add a formbean declaration (with a different > name) > > for your action form, and also add another mapping for the same action. > It > > can be the same ActionForm and Action object, but would need different > > mappings in struts-config. > > > I tried this, but it causes other problems. For example, on the > resulting JSP, there are tags which need to refer to the > form name. But when I have two possible action-mappings with two form > beans, I have no way of knowing which one is being used. I suppose I > could use logic tags to test for this, but it would mean a lot of > duplicated code. > > I tried writing a tag which extends , and this seems to work. > I added an attribute for the form name, so it can be set independently > of the bean name. I'll probably also have to extend the JavaScript > validator tag if I want to use that, since it needs the form name as > well. > > But it would be nice if this were built into Struts. > > Jacob > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Specifying HTML form names
In article <[EMAIL PROTECTED]>, Hubert Rabago <[EMAIL PROTECTED]> wrote: > There was only one entry for the two similarly named forms. Checking the > fields of the form showed me that only the latest definition of a form with a > given name is recognized. > > So, you should probably add a formbean declaration (with a different name) > for your action form, and also add another mapping for the same action. It > can be the same ActionForm and Action object, but would need different > mappings in struts-config. I tried this, but it causes other problems. For example, on the resulting JSP, there are tags which need to refer to the form name. But when I have two possible action-mappings with two form beans, I have no way of knowing which one is being used. I suppose I could use logic tags to test for this, but it would mean a lot of duplicated code. I tried writing a tag which extends , and this seems to work. I added an attribute for the form name, so it can be set independently of the bean name. I'll probably also have to extend the JavaScript validator tag if I want to use that, since it needs the form name as well. But it would be nice if this were built into Struts. Jacob - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Specifying HTML form names
Just sharing a simple test I just did. It looks that you can't have two forms with the same name on one document. I created a page with two forms with the same name, then checked how the browser sees them with a quick javascript: var result = "Forms in this document:\n\n"; for (var i=0; i < document.forms.length; i++) { result = result + "document.forms[" + i + "]=" + document.forms[i] + "\n"; result = result + "document.forms[" + i + "].name=" + document.forms[i].name + "\n\n"; } alert(result); There was only one entry for the two similarly named forms. Checking the fields of the form showed me that only the latest definition of a form with a given name is recognized. So, you should probably add a formbean declaration (with a different name) for your action form, and also add another mapping for the same action. It can be the same ActionForm and Action object, but would need different mappings in struts-config. - Hubert --- Jacob Weber <[EMAIL PROTECTED]> wrote: > > I have a JSP with two forms, and they both need to go to the same > action. But Struts assumes that the "name" property of the HTML form > (e.g. ) should be the same as the name of the > associated form bean. As a result, I can't use JavaScript to refer to > one of the forms, since they both have the same name. > > Is this a situation where I need to write my own version of ? > Why does Struts make this assumption? > > Things I've already considered: > > - Using two different actions with different form beans. This doesn't > work, since the JSP needs to refer to the form bean by name (for > example, in ). If I use two actions that return the same > JSP, they need to use the same form bean. > > - Combining the two forms into one. This doesn't work in my situation, > since the forms need to submit different values for the same fields. > > - Referring to the forms by number in my JavaScript (e.g. > document.forms[0]). This doesn't work, since there may be other forms on > the page, which would throw off the numbering. > > Any ideas? > Thanks, > Jacob > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > __ 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]
Specifying HTML form names
I have a JSP with two forms, and they both need to go to the same action. But Struts assumes that the "name" property of the HTML form (e.g. ) should be the same as the name of the associated form bean. As a result, I can't use JavaScript to refer to one of the forms, since they both have the same name. Is this a situation where I need to write my own version of ? Why does Struts make this assumption? Things I've already considered: - Using two different actions with different form beans. This doesn't work, since the JSP needs to refer to the form bean by name (for example, in ). If I use two actions that return the same JSP, they need to use the same form bean. - Combining the two forms into one. This doesn't work in my situation, since the forms need to submit different values for the same fields. - Referring to the forms by number in my JavaScript (e.g. document.forms[0]). This doesn't work, since there may be other forms on the page, which would throw off the numbering. Any ideas? Thanks, Jacob - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validwhen with checkboxes (1.2)
Nathan -- try changing the logical to "and" Nathan Maves wrote: can you run a check to see if a checkbox has been selected? This doesn't seem to work for me, where rollable is a checkbox in the same form. I want this field to be required when the rollable checkbox is checked. test ((rollable == null) or (*this* == null)) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problem occured while validating form
when validating form,some problems occured. As MVC Model2 suggest,I use a controller to query imformations and store them into javabeans.Then the javabeans is used by the page which contains a form. when the form submits,the form is validated.If some errors occured,struts will return to input page.As the input page need some informations to render the page,so I make the struts return to the controller which queries information required by the input page.some informations may be changed when the form submitted,but the controller doesn't know this. How to solve this problem? I use two controller.One is used when user requests the page at the first time.Another is used when validating errors occur. _ Do You Yahoo!? 150万曲MP3疯狂搜,带您闯入音乐殿堂 http://music.yisou.com/ 美女明星应有尽有,搜遍美图、艳图和酷图 http://image.yisou.com 1G就是1000兆,雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to call multiple submits in a jsp form(in STRUTS other than using javascript)
Hi Manjo, Have a look at the documentation for the LookupDispatchAction. This should do what you want. Regards, Jeff - Original Message - From: "jacob skariah" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, August 14, 2004 8:07 AM Subject: How to call multiple submits in a jsp form(in STRUTS other than using javascript) > Hi, > >Is there any better way to call multiple submits in > a jsp form using Struts without using javascripts. > > I have to call diffrent actions on each submit,(say > listing , deleting and adding) , this can be easily > done through scripts , but what if scripts is > disabled. > > Does Struts have any better solution. > > Thanx in Advance > > Regards > > manoj > > > > __ > Do you Yahoo!? > New and Improved Yahoo! Mail - Send 10MB messages! > 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]