Re: [Stripes-users] Two dimensional arrays in actions
My guess as to why it might not be good to name a form button submit is that form elements can be referenced with formNode.formElementName, but each form node already has a property named submit that references the submit function. I guess the function would win, but I'm not sure. -Ben On Tue, Nov 29, 2011 at 11:29 PM, Nathan Robertson nath...@nathanr.netwrote: Hi Freddy, Thanks for the help. Further comments inline. On 30 November 2011 15:12, Freddy Daoud xf2...@fastmail.fm wrote: [...] Not a big deal, but note that you can use just beanclass=${actionBean.class} in s:form. Noted. Thank you. [...] I don't think this affects your code, but I would really advise against using an event handler method named submit. I can't remember why exactly at the moment, but I remember that it's a Really Bad Idea to have an HTML submit button named submit. Noted. Thank you. I've got a fair bit of code that uses submit(), so I'll be doing a fair bit of refactoring. :-) My experience when dealing with one dimensional arrays (changing answer[][] to answer1[], answer2[]) is that you get an array of answers propagated for you. eg. If you speak both English and French, you get answer2[] = {1, 2}; if you live in Australia you get answer1[] = {1} So, I would have thought that with the example I list the code for, if you live in Australia and speak English and French you should get answer[][] = {{}, {1}, {1, 2}} (my arrays are one indexed, so the zero index should be null or an empty array). Is this not the case? I would have thought so too. I'll admit I am surprised. I'm not sure why it doesn't work, but I can tell you that if you change your property to public ListListString answer; you will get what you expect, i.e. answer = [null, [1], [1, 2]] I'm hoping you don't mind working with ListListString instead of String[][].. Making that one change solved the problem. ListListString works perfectly, String[][] doesn't. So I'm guessing that's a bug? At least there's a workaround, and it's not a bad one. Thanks again for your help. Should I be opening a bug report for this one? Regards, Nathan. -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d___ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users
Re: [Stripes-users] Two dimensional arrays in actions
Hi Nathan, A few comments below. Hope that helps. [...] s:form beanclass=${actionBean.class.name} name=frmExam p(Q1). In which country were you born?/p ps:radio name=answer[1] value=1/Australia/p ps:radio name=answer[1] value=2/Other/p pnbsp;/p p(Q2). Do you speak any of these languages?/p ps:checkbox name=answer[2] value=1/English/p ps:checkbox name=answer[2] value=2/French/p pnbsp;/p [...] Not a big deal, but note that you can use just beanclass=${actionBean.class} in s:form. And an action that looks like this: public class SomeAction { public String[][] answer = null; @DefaultHandler public Resolution submit() { if (answer == null) logger.debug(No answers provided by customer); else logger.debug(String.format(answer[][] first dimension is %d items long, answer.length)); } } I don't think this affects your code, but I would really advise against using an event handler method named submit. I can't remember why exactly at the moment, but I remember that it's a Really Bad Idea to have an HTML submit button named submit. When I answer the questions and submit, my debugging output says answer[][] first dimension is 0 items long. So answer gets set to a non-null, but of zero length. My reading of the section of the (excellent) stripes book on indexed properties suggests that I might be able to do this, but doesn't give an example that maps to exactly what I'm doing. Thank you for your kind comment about the book--I'm glad you are enjoying it. Sorry that I didn't have an example that matches your use case.. My experience when dealing with one dimensional arrays (changing answer[][] to answer1[], answer2[]) is that you get an array of answers propagated for you. eg. If you speak both English and French, you get answer2[] = {1, 2}; if you live in Australia you get answer1[] = {1} So, I would have thought that with the example I list the code for, if you live in Australia and speak English and French you should get answer[][] = {{}, {1}, {1, 2}} (my arrays are one indexed, so the zero index should be null or an empty array). Is this not the case? I would have thought so too. I'll admit I am surprised. I'm not sure why it doesn't work, but I can tell you that if you change your property to public ListListString answer; you will get what you expect, i.e. answer = [null, [1], [1, 2]] I'm hoping you don't mind working with ListListString instead of String[][].. If it's an issue, I'll look further into why it doesn't work with the two-dimensional array. Cheers, Freddy -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users
Re: [Stripes-users] Two dimensional arrays in actions
Hi Freddy, Thanks for the help. Further comments inline. On 30 November 2011 15:12, Freddy Daoud xf2...@fastmail.fm wrote: [...] Not a big deal, but note that you can use just beanclass=${actionBean.class} in s:form. Noted. Thank you. [...] I don't think this affects your code, but I would really advise against using an event handler method named submit. I can't remember why exactly at the moment, but I remember that it's a Really Bad Idea to have an HTML submit button named submit. Noted. Thank you. I've got a fair bit of code that uses submit(), so I'll be doing a fair bit of refactoring. :-) My experience when dealing with one dimensional arrays (changing answer[][] to answer1[], answer2[]) is that you get an array of answers propagated for you. eg. If you speak both English and French, you get answer2[] = {1, 2}; if you live in Australia you get answer1[] = {1} So, I would have thought that with the example I list the code for, if you live in Australia and speak English and French you should get answer[][] = {{}, {1}, {1, 2}} (my arrays are one indexed, so the zero index should be null or an empty array). Is this not the case? I would have thought so too. I'll admit I am surprised. I'm not sure why it doesn't work, but I can tell you that if you change your property to public ListListString answer; you will get what you expect, i.e. answer = [null, [1], [1, 2]] I'm hoping you don't mind working with ListListString instead of String[][].. Making that one change solved the problem. ListListString works perfectly, String[][] doesn't. So I'm guessing that's a bug? At least there's a workaround, and it's not a bad one. Thanks again for your help. Should I be opening a bug report for this one? Regards, Nathan. -- All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d ___ Stripes-users mailing list Stripes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/stripes-users