Re: James Sanders wants to chat
Wow does this list seem very small at the moment. On 12/10/07, Paul Benedict <[EMAIL PROTECTED]> wrote: > > LOLOL > > On Dec 10, 2007 11:06 AM, Dave Newton <[EMAIL PROTECTED]> wrote: > > > --- James Sanders <[EMAIL PROTECTED]> wrote: > > > James Sanders wants to stay in better touch using some of Google's > > coolest > > > new products. > > > > Only sports stars get to refer to themselves in the third person. > > > > d. > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > >
Re: James Sanders wants to chat
On 12/10/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > --- James Sanders <[EMAIL PROTECTED]> wrote: > > James Sanders wants to stay in better touch using some of Google's > coolest > > new products. > > Only sports stars get to refer to themselves in the third person. Bob Dole is a sports star ?
Struts and Quartz
Hi all, working with a struts application that I am trying to add quartz to but I am running into a slight snag. I can't seem to get the scheduler to be recognized. I am trying to follow the following tutorial: http://www.onjava.com/pub/a/onjava/2006/03/01/job-scheduling-in-web-application.html Unfortunately I am running into errors at the point of setting up the servletcontext. I am trying to use their sample code, as I don't know what it would be otherwise. thanks in advance for any help or suggestions on this matter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: test
It's a bit annoying, but I suppose it's to try and avoid mail loops/excess inbox junk. It's not that difficult to search your inbox or bcc yourself though. On 12/6/06, James Mitchell <[EMAIL PROTECTED]> wrote: That's because GMail doesn't send you your own postings. On 12/6/06, nicolas de loof <[EMAIL PROTECTED]> wrote: > > It seems to work ! > > Just was curious not getting messages I send to the list in my mail box. > > 2006/12/6, Adam K <[EMAIL PROTECTED]>: > > > > You had a question if it would work ? > > > > > > > > On 12/6/06, nicolas de loof <[EMAIL PROTECTED]> wrote: > > > > > > Please ignore ... > > > > > > just testing my gMail account. > > > > > > > > > > > > -- James Mitchell 678.910.8017
Re: test
You had a question if it would work ? On 12/6/06, nicolas de loof <[EMAIL PROTECTED]> wrote: Please ignore ... just testing my gMail account.
Re: Indexed Properties
Just thought that I would say that the following will be incredibly helpful to anyone working on indexed properties in the future: (It has a complete working example) http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=009880 thanks to everyone for all of the help. On 11/23/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote: On 11/22/06, Adam K <[EMAIL PROTECTED]> wrote: > > If you might be able to provide a sample I would be very greatful. > As it stands I have come up with the following : > changing the JSP to : > > > id="Result"> > indexed="true" /> > > > Hmm.. As i said try something like this In case you dont encounter any error while loading the page. please post the HTML generated. That would give a good idea of what is going wrong. Result seemed more natural as it is a single element of the results. > All I want to be able to do is pull 3 things out of an object, display > them > in a scope of request, and allow the user to update the list and submit > the > form and have the changes be picked up - who would have thought that would > be so incredibly complex ? > *Note* The part that leads me to believe it's a misunderstanding of the > tags involved is that I can get a single textfield to work perfectly, with > all the requirements (other than it being an object with multiple > properties). > > > On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: > > > > hi Adam, > > > > I understand description,numProducts are properties in User defined > > Object/java bean in results(getResults(),setResults(..)) Collection in > > your > > actionForm. > > > > For this kind of requirments there will not be any change in actionform > > even > > though ,complixety increases in nesting.. > > > > Solution is to use Nested Tags. > > > > Nested tags are used for nesting a object inside the other. > > > > In your requirment "results" is a nested property in your actionform. > > "results" collection has a collection of objects. > > > > I have used Nested tags for most complex requirments and succeeded. > > > > Nested Tags is the real power of Struts... > > > > > > Regards > > Raghu > > > > > > > > > > > > -Original Message- > > From: Adam K [mailto:[EMAIL PROTECTED] > > Sent: Saturday, November 18, 2006 2:55 AM > > To: Struts Users Mailing List > > Subject: Re: Indexed Properties > > > > > > Thanks for the suggestion I'll keep trying things and see what I can get > > from it. > > > > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > > > Lots of people have done it. Search the archives [1]. Search for > > > "indexed" and "lazyList". I've done it with both ActionForm and > > > DynaActionForm. > > > > > > Hubert > > > > > > [1] http://struts.apache.org/mail.html > > > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > I think I have found the problem - or at least a potential > > cause. Would > > > it > > > > be correct in stating that this will not work using ActionForm (what > I > > > was > > > > using) and that I must instead use DynaActionForm ? > > > > > > > > Thanks for the time thus far. > > > > > > > > > > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Adam, > > > > > > > > > > Try adding a getResultsPage() that doesn't take params and always > > > > > returns a valid collection. (Throw in the setResultsPage() that > > > > > accepts a collection as well.) > > > > > > > > > > Hubert > > > > > > > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > > > This has been driving me nuts for the past little bit. > > > > > > I have a page that is populated using indexed properties. The > > > > > prepopulation > > > > > > works fine, and I get the results as I would expect them, but > > > trying to > > > > > > submit the form I get an index out of bounds exception. I know > > that > > > it > > > > > is > > > > > > being caused because the page doesn't have the arrayLi
Re: Indexed Properties with nested Tags
Alright, I guess I should have thought that. I was worried that my fundamental understanding for this was wrong. For debugging I am putting my information into a String which is not being iterated (it for some reason always works, but those that are iterated over don't for some reason. I have no problem prepopulating, and no problem showing the form again, it's only when I try to have what the user inputs get placed into the form that is where I am lost. thanks once again for all the help everyone, sorry if I sound like a broken record. On 11/22/06, Dave Newton <[EMAIL PROTECTED]> wrote: From: Adam K [mailto:[EMAIL PROTECTED] > What is the purpose of the System.out.println that you have at the end > of your action ? Debugging? Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Indexed Properties with nested Tags
I should also like to say that the one part that seems to be giving me the most problem is the setting of the variables in action when it is submitted. The other thing I am curious about is if what I am doing is incorrect. I am using one action for both the submit as well as the prepopulate based on a url parameter. thanks once again. Adam On 11/22/06, Adam K <[EMAIL PROTECTED]> wrote: Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: > > Hi Adam, > > Use the sample code as requested by you. > You can ask me any help with nested Tags and from advanced struts > > > > > *JSP* > > > > id="Result" type="com.test.javabeans.TestObject"> > > > > > > > > *ActionForm* > ** > public class ProdSelectionForm extends ActionForm > { > Collection arlResults=null; //can be arrayalist > > /** > * @return Returns the arlResults. > */ > public Collection getResults() { > return arlResults; > } > /** > * @param arlResultsThe arlResultsto set. > */ > public void setResults(Collection arlResults) { > this.arlResults= arlResults; > } > > /** > * > * toString representation of object > * @return An instance of StringBuffer with Struts Action Form > properties > * > */ > public String toString() { > >StringBuffer sbTemp = new StringBuffer(); >sbTemp.append("{"); > >sbTemp.append("arlResults=" ); >sbTemp.append(arlResults); >sbTemp.append("}"); >return sbTemp.toString(); > > }//end of toString > }//end Actionform > > *TestObject Java Bean* > > import java.io.Serializable; > > public class TestObject implements Serializable > > String description =null; > int numProducts =0; > /** > * @return Returns the description. > */ > public String getDescription() { > return description; > } > /** > * @param description The description to set. > */ > public void setDescription(String description) { > this.description = description; > } > /** > * @return Returns the numProducts. > */ > public int getNumProducts() { > return numProducts; > } > /** > * @param numProducts The numProducts to set. > */ > public void setNumProducts(int numProducts) { > this.numProducts = numProducts; > } > > }//end object > ** > > *Action Class (loading the page)* > ** > ** > ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; > com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); > obj1.setDescription("desc1"); > obj1.setNumProducts (1); > > com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject(); > obj1.setDescription("desc2"); > obj1.setNumProducts (2); > > ArrayList arlResults=new ArrayList (); > arlResults.add(obj1); > arlResults.add(obj2); > > prodSelectionForm.setResults(arlResults); > > *Action Class (Submitting the page)* > > When you submit the page just print the actionform you wouyld see the > updated results of description ,numproducts in action > > ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; > > System.out.println("prodSelectionForm="+prodSelectionForm); > > > > Regards > Raghu > > -Original Message- > *From:* Adam K [mailto:[EMAIL PROTECTED] > *Sent:* Wednesday, November 22, 2006 3:06 AM > *To:* [EMAIL PROTECTED] > *Cc:* Struts Users Mailing List > *Subject:* Re: Indexed Properties > > If you might be able to provide a sample I would be very greatful. > As it stands I have come up with the following : > changing the JSP to : > > > id="Result"> > > indexed="true" /> > > > > > Result seemed more natural as it is a single element of the results. > All I want to be able to do is pull 3 things out of an object, display > them in a scope of request, and allow the user to update the list and submit > the form and have the changes be picked up - who would
Re: Indexed Properties with nested Tags
Thanks for the lengthy example, but there is one part that I am completly lost on. I thought that the following occurred: Click link to open page, formbean is reset aciton poppulates formbean jsp retrieves values from the formbean. User sees the screen prepopulated. User modifies the information and clicks on submit. The bean is again reset the action is called to put information in the formbean (this is the part I have no data) the jsp then pulls the data from the formbean. What is the purpose of the System.out.println that you have at the end of your action ? thanks again, Adam On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: Hi Adam, Use the sample code as requested by you. You can ask me any help with nested Tags and from advanced struts *JSP* *ActionForm* ** public class ProdSelectionForm extends ActionForm { Collection arlResults=null; //can be arrayalist /** * @return Returns the arlResults. */ public Collection getResults() { return arlResults; } /** * @param arlResultsThe arlResultsto set. */ public void setResults(Collection arlResults) { this.arlResults= arlResults; } /** * * toString representation of object * @return An instance of StringBuffer with Struts Action Form properties * */ public String toString() { StringBuffer sbTemp = new StringBuffer(); sbTemp.append("{"); sbTemp.append("arlResults=" ); sbTemp.append(arlResults); sbTemp.append("}"); return sbTemp.toString(); }//end of toString }//end Actionform *TestObject Java Bean* import java.io.Serializable; public class TestObject implements Serializable String description =null; int numProducts =0; /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the numProducts. */ public int getNumProducts() { return numProducts; } /** * @param numProducts The numProducts to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } }//end object ** *Action Class (loading the page)* ** ** ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; com.test.javabeans.TestObject obj1=new com.test.javabeans.TestObject (); obj1.setDescription("desc1"); obj1.setNumProducts (1); com.test.javabeans.TestObject obj2=new com.test.javabeans.TestObject (); obj1.setDescription("desc2"); obj1.setNumProducts (2); ArrayList arlResults=new ArrayList (); arlResults.add(obj1); arlResults.add(obj2); prodSelectionForm.setResults(arlResults); *Action Class (Submitting the page)* When you submit the page just print the actionform you wouyld see the updated results of description ,numproducts in action ProdSelectionForm prodSelectionForm= (ProdSelectionForm) form; System.out.println("prodSelectionForm="+prodSelectionForm); Regards Raghu -Original Message- *From:* Adam K [mailto:[EMAIL PROTECTED] *Sent:* Wednesday, November 22, 2006 3:06 AM *To:* [EMAIL PROTECTED] *Cc:* Struts Users Mailing List *Subject:* Re: Indexed Properties If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: > > hi Adam, > > I understand description,numProducts are properties in User defined > Object/java bean in results(getResults(),setResults(..)) Collection in > your > actionForm. > > For this kind of requirments there will not be any change in actionform > even > though ,complixety increases in nesting.. > > Solution is to use Nested Tags. > > Nested tags are used for nesting a object inside the other. > > In your requirment "results" is a nested property in your actionform. > "results" collection has a collection of objects. > > I have used Nested tags for most complex requirments and succeeded. > > Nested Tags is the real power of Struts... > > > Regards > Raghu > > > > > > -Original Message- > From: Adam K [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 18, 2006 2:55
Indexed Property and Hand Cranking Lazy List
Hello all, I am sorry to subject this list to yet another person who doesn't understand something, but I can't for the life of me figure out hand cranking lazy lists. I am using 1.2.9 with java 1.5.0_06 And I can't get lazy lists to work. I am trying to use what I found at : http://wiki.apache.org/struts/StrutsCatalogLazyList And as such have : In the ProdSelectionFrom: private List skills = new ArrayList(); public List getSkills() { return skills; } // non-bean version so as not to confuse struts. public void populateSkills(List skills) { this.skills.addAll(skills); } public void setSkills(Product skill) { this.skills.add(skill); } public Product getSkills(int index) { // automatically grow List size while (index >= skills.size()) { skills.add(new Product()); } return (Product)skills.get(index); } In the JSP: And can't even get this to display properly. I am getting the error message: No getter method for property: "skills" of bean: "ProdSelectionForm" javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method for property: "skills" of bean: "ProdSelectionForm" Could someone please point me in the right direction as I am at my wits end on this. The entire point of what I am trying to do is to be able to post a list of information about a product (such as description, number, price etc) and allow the user to edit the number and have them submit the form so that I can update a database with a new order. I am using a product Object which has all of the characteristics mentioned before as well as others, and each of them have publically available getter and setter methods. I would also like to confirm that the comment I read that I should be using strictly strings when dealing with the jsp is correct - can someone confirm that ? Also is there a problem using ArrayList over List ? Thanks so much for any thoughts/ time you can give me.
Re: Indexed Properties
If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : Result seemed more natural as it is a single element of the results. All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: hi Adam, I understand description,numProducts are properties in User defined Object/java bean in results(getResults(),setResults(..)) Collection in your actionForm. For this kind of requirments there will not be any change in actionform even though ,complixety increases in nesting.. Solution is to use Nested Tags. Nested tags are used for nesting a object inside the other. In your requirment "results" is a nested property in your actionform. "results" collection has a collection of objects. I have used Nested tags for most complex requirments and succeeded. Nested Tags is the real power of Struts... Regards Raghu -----Original Message- From: Adam K [mailto:[EMAIL PROTECTED] Sent: Saturday, November 18, 2006 2:55 AM To: Struts Users Mailing List Subject: Re: Indexed Properties Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > Lots of people have done it. Search the archives [1]. Search for > "indexed" and "lazyList". I've done it with both ActionForm and > DynaActionForm. > > Hubert > > [1] http://struts.apache.org/mail.html > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > I think I have found the problem - or at least a potential cause. Would > it > > be correct in stating that this will not work using ActionForm (what I > was > > using) and that I must instead use DynaActionForm ? > > > > Thanks for the time thus far. > > > > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > > > Adam, > > > > > > Try adding a getResultsPage() that doesn't take params and always > > > returns a valid collection. (Throw in the setResultsPage() that > > > accepts a collection as well.) > > > > > > Hubert > > > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > This has been driving me nuts for the past little bit. > > > > I have a page that is populated using indexed properties. The > > > prepopulation > > > > works fine, and I get the results as I would expect them, but > trying to > > > > submit the form I get an index out of bounds exception. I know that > it > > > is > > > > being caused because the page doesn't have the arrayList to use in > the > > > > indexed properties. I guess my question boils down to using > indexed > > > > properties properly. I will start by putting in an explanation of > what > > > I > > > > have and what I am trying to do: > > > > > > > > The following is what I am working with : > > > > JSP: > > > > > > > > > > > > > > > id="ResultsPage"> > > > > > > > > > > property="description" > > > > /> > > > > > > property="numProducts" > > > > indexed="true" /> > > > > > > > > > > > > > > > > > > > > What I am trying to achieve is that a user clicks on a link, they > are > > > sent > > > > to page, and all of the values are prepopulated. The page is then > > > displayed > > > > and the user has the option to modify any of the variables that they > > > want to > > > > before resubmitting the page. (When they resubmit the form has a > url > > > > parameter attached to it). What is happening (or at least what I > > > believe is > > > > happening is the following: link is clicked, reset is called action > > > sets > > > > the variables, page is displayed, user can modify the page and > resubmit, > > > > reset
Re: Indexed Properties
Thanks for the suggestion I'll keep trying things and see what I can get from it. On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: Lots of people have done it. Search the archives [1]. Search for "indexed" and "lazyList". I've done it with both ActionForm and DynaActionForm. Hubert [1] http://struts.apache.org/mail.html On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > I think I have found the problem - or at least a potential cause. Would it > be correct in stating that this will not work using ActionForm (what I was > using) and that I must instead use DynaActionForm ? > > Thanks for the time thus far. > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > Adam, > > > > Try adding a getResultsPage() that doesn't take params and always > > returns a valid collection. (Throw in the setResultsPage() that > > accepts a collection as well.) > > > > Hubert > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > This has been driving me nuts for the past little bit. > > > I have a page that is populated using indexed properties. The > > prepopulation > > > works fine, and I get the results as I would expect them, but trying to > > > submit the form I get an index out of bounds exception. I know that it > > is > > > being caused because the page doesn't have the arrayList to use in the > > > indexed properties. I guess my question boils down to using indexed > > > properties properly. I will start by putting in an explanation of what > > I > > > have and what I am trying to do: > > > > > > The following is what I am working with : > > > JSP: > > > > > > > > > > > id="ResultsPage"> > > > > > > > property="description" > > > /> > > > > property="numProducts" > > > indexed="true" /> > > > > > > > > > > > > > > > What I am trying to achieve is that a user clicks on a link, they are > > sent > > > to page, and all of the values are prepopulated. The page is then > > displayed > > > and the user has the option to modify any of the variables that they > > want to > > > before resubmitting the page. (When they resubmit the form has a url > > > parameter attached to it). What is happening (or at least what I > > believe is > > > happening is the following: link is clicked, reset is called action > > sets > > > the variables, page is displayed, user can modify the page and resubmit, > > > reset is called on the form, the action is called (this is where it dies > > as > > > there is no longer an ArrayList) to modify. My question is am I going > > about > > > this in a manner that seems sensible or am I way off base ? I have the > > > values being prepopulated, but when trying to use the values that the > > user > > > puts in I can't use them in the action, nor can I pull the values from > > the > > > form without again setting the values in the form. I am hoping it is > > that > > > I have over looked something, but it's possible that I don't understand > > > something as well. > > > > > > Here is the Action code (This is the entire execute method) : > > > HttpSession session = request.getSession(); > > > ProdSelectionForm prodSelection = (ProdSelectionForm) form; > > > User user ; > > > user = (User)session.getAttribute("User"); > > > Order order = new Order(); > > > ArrayList products = new ArrayList(); > > > ArrayList pageRes = new ArrayList(); > > > ArrayList results = new ArrayList(); > > > > > > String action = (request.getParameter("Dest") == null ? > > "populate" : > > > request.getParameter("Dest") ); > > > > > > order = user.getCurrOrder(user); > > > > > > if(action.equals("populate")) > > > { > > > prodSelection.setResults(order.getProducts()); > > > } > > > > > > if(action.equals("Delete")) > > > { > > > ArrayList p = new ArrayList(); > > > p = prodSelection.getResults(); > > > > > > int
Re: Indexed Properties
I think I have found the problem - or at least a potential cause. Would it be correct in stating that this will not work using ActionForm (what I was using) and that I must instead use DynaActionForm ? Thanks for the time thus far. On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: Adam, Try adding a getResultsPage() that doesn't take params and always returns a valid collection. (Throw in the setResultsPage() that accepts a collection as well.) Hubert On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > This has been driving me nuts for the past little bit. > I have a page that is populated using indexed properties. The prepopulation > works fine, and I get the results as I would expect them, but trying to > submit the form I get an index out of bounds exception. I know that it is > being caused because the page doesn't have the arrayList to use in the > indexed properties. I guess my question boils down to using indexed > properties properly. I will start by putting in an explanation of what I > have and what I am trying to do: > > The following is what I am working with : > JSP: > > > id="ResultsPage"> > > /> > indexed="true" /> > > > > > What I am trying to achieve is that a user clicks on a link, they are sent > to page, and all of the values are prepopulated. The page is then displayed > and the user has the option to modify any of the variables that they want to > before resubmitting the page. (When they resubmit the form has a url > parameter attached to it). What is happening (or at least what I believe is > happening is the following: link is clicked, reset is called action sets > the variables, page is displayed, user can modify the page and resubmit, > reset is called on the form, the action is called (this is where it dies as > there is no longer an ArrayList) to modify. My question is am I going about > this in a manner that seems sensible or am I way off base ? I have the > values being prepopulated, but when trying to use the values that the user > puts in I can't use them in the action, nor can I pull the values from the > form without again setting the values in the form. I am hoping it is that > I have over looked something, but it's possible that I don't understand > something as well. > > Here is the Action code (This is the entire execute method) : > HttpSession session = request.getSession(); > ProdSelectionForm prodSelection = (ProdSelectionForm) form; > User user ; > user = (User)session.getAttribute("User"); > Order order = new Order(); > ArrayList products = new ArrayList(); > ArrayList pageRes = new ArrayList(); > ArrayList results = new ArrayList(); > > String action = (request.getParameter("Dest") == null ? "populate" : > request.getParameter("Dest") ); > > order = user.getCurrOrder(user); > > if(action.equals("populate")) > { > prodSelection.setResults(order.getProducts()); > } > > if(action.equals("Delete")) > { > ArrayList p = new ArrayList(); > p = prodSelection.getResults(); > > int count = 0; > while (count < p.size()) > { > Product t = (Product) p.get(count); > t.setDescription("" +t.getNumProducts() +">" +pageRes.size() > +"<"); > p.set(count, t); > count++; > } > > t.setDescription("" +t.getNumProducts() +">" +p.size() +"<"); > p.set(0, t); > > user.setOrder(p , user); > prodSelection.setResults(p); > prodSelection.setTest(prodSelection.getTest()+" + " + p.size ()); > > return mapping.findForward("success"); > } > return mapping.findForward("success"); > > > > > Form code: (In the form code is an ArrayList called results. This arraylist > contains a bunch of Product ) > > public Product getResultsPage(int index) > { > if(this.results == null) > { > this.results = new ArrayList(); > } > > while(index >= this.results.size()) > { > this.results.add(new Product()); > } > return (Product) results.get(index); > } > > public void setResultsPage(int index, Product p) > { >
Indexed Properties
This has been driving me nuts for the past little bit. I have a page that is populated using indexed properties. The prepopulation works fine, and I get the results as I would expect them, but trying to submit the form I get an index out of bounds exception. I know that it is being caused because the page doesn't have the arrayList to use in the indexed properties. I guess my question boils down to using indexed properties properly. I will start by putting in an explanation of what I have and what I am trying to do: The following is what I am working with : JSP: What I am trying to achieve is that a user clicks on a link, they are sent to page, and all of the values are prepopulated. The page is then displayed and the user has the option to modify any of the variables that they want to before resubmitting the page. (When they resubmit the form has a url parameter attached to it). What is happening (or at least what I believe is happening is the following: link is clicked, reset is called action sets the variables, page is displayed, user can modify the page and resubmit, reset is called on the form, the action is called (this is where it dies as there is no longer an ArrayList) to modify. My question is am I going about this in a manner that seems sensible or am I way off base ? I have the values being prepopulated, but when trying to use the values that the user puts in I can't use them in the action, nor can I pull the values from the form without again setting the values in the form. I am hoping it is that I have over looked something, but it's possible that I don't understand something as well. Here is the Action code (This is the entire execute method) : HttpSession session = request.getSession(); ProdSelectionForm prodSelection = (ProdSelectionForm) form; User user ; user = (User)session.getAttribute("User"); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList pageRes = new ArrayList(); ArrayList results = new ArrayList(); String action = (request.getParameter("Dest") == null ? "populate" : request.getParameter("Dest") ); order = user.getCurrOrder(user); if(action.equals("populate")) { prodSelection.setResults(order.getProducts()); } if(action.equals("Delete")) { ArrayList p = new ArrayList(); p = prodSelection.getResults(); int count = 0; while (count < p.size()) { Product t = (Product) p.get(count); t.setDescription("" +t.getNumProducts() +">" +pageRes.size() +"<"); p.set(count, t); count++; } t.setDescription("" +t.getNumProducts() +">" +p.size() +"<"); p.set(0, t); user.setOrder(p , user); prodSelection.setResults(p); prodSelection.setTest(prodSelection.getTest()+" + " + p.size()); return mapping.findForward("success"); } return mapping.findForward("success"); Form code: (In the form code is an ArrayList called results. This arraylist contains a bunch of Product ) public Product getResultsPage(int index) { if(this.results == null) { this.results = new ArrayList(); } while(index >= this.results.size()) { this.results.add(new Product()); } return (Product) results.get(index); } public void setResultsPage(int index, Product p) { if(this.results == null) { this.results = new ArrayList(); } while(index >= this.results.size()) { this.results.add(new Product()); } results.set(index, p); //return (Product) results.get(index); } public void setResults(ArrayList results) { this.results=results; } public ArrayList getResults() { return this.results; } Products is an object that stores various things about a product with numProducts, and description being two of those things. Within Products is both getter and setter methods for the numProducts as well as description. Thanks so much for any help you may be able to provide.
Re: setting an an html:text value with another html:text
That will work I suppose I was just hoping that there was a somewhat more elegant way of doing it, the fact that I'm not using JSTL should have hit me in the face that this wouldn't be elegant however. thanks for the thought. On 11/14/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote: On 11/14/06, Adam K <[EMAIL PROTECTED]> wrote: > > Hi all , I am attempting to do the following, and it obviously isn't > working, but I was hoping someone on the list would point me to something > that might work instead: > > I have this text field and I want to be able to alternate the readonly > property from true and false. I tried to put in the below which is bolded > > readonly="WANTTOTOGGLE" > > > > readonly="" > > > > Any thoughts or ideas as to how I could do that in a nice manner would be > greatly appreciated. > > What is going to happen is that the action is going to toggle the value > depending on a parameter comming in from the URL. so supposing your url has something like this http://foo.com/bar.do?editable=true Then you could have in your JSP false true true So now your text box would have I know this is unclean but just doing bean write instead of the scriptlet thing didnt work for me. You could probably clean up the logic tags also. But i havent ever done JSTL so... thanks in advance for any thoughts or ideas. > > Hope it helps -- Puneet
setting an an html:text value with another html:text
Hi all , I am attempting to do the following, and it obviously isn't working, but I was hoping someone on the list would point me to something that might work instead: I have this text field and I want to be able to alternate the readonly property from true and false. I tried to put in the below which is bolded " Any thoughts or ideas as to how I could do that in a nice manner would be greatly appreciated. What is going to happen is that the action is going to toggle the value depending on a parameter comming in from the URL. thanks in advance for any thoughts or ideas.
Re: Using html:errors with a field that is iterated.
On 11/3/06, robin bajaj <[EMAIL PROTECTED]> wrote: Hi Adam, Yes, I think html:errors is a pretty good validaiton mechanism. Especially if you use the Struts validation framework (validation.xml, validator-rules.xml) for generating your errors. Yes I am using validation.xml and validator-rules.xml. For showing errors right beside each specific field that fails the validation, you will need to have tag beside each field. For this question I was more curious about those fields that are being generated by using an iterator, which means there may be many fields with the same validation needs, but I won't know how many fields there are. Basically I am wondering if there is a manner to use error validation to preform validation on a list that may have from zero to hundreds of elements. The list that I am using is being created by : Hopefully that question makes sense. But if you want to show all the errors at once (say above all the fields) then you can use tag as-is. Check this link for more info : (this link is not _outdated) http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html#section2 hope this helps, thanks for the help so far. robin On 11/3/06, Adam K <[EMAIL PROTECTED]> wrote: > > Hi all I am using struts 1.2.9 and starting to work on error > validation. So > far I have my login page using: > > > etc etc etc. > > I was wondering firstly Is this still the best manner in which to display > errors ? > > > The second question which has more to do with the title is > How does one use error validation on fields that are iterated ? > > As an example if I have 3 fields where a team has to enter a score, I want > to ensure that the only values that are entered beside each field is a > number. If any of those fields have other than a number I want the error > to > appear only beside that particular field. Is this something that can be > done with error validation ? I am looking around for examples but most > examples are quite dated and I am trying to use the best things available > to > me. > > thanks in advance. > Adam > >
Using html:errors with a field that is iterated.
Hi all I am using struts 1.2.9 and starting to work on error validation. So far I have my login page using: etc etc etc. I was wondering firstly Is this still the best manner in which to display errors ? The second question which has more to do with the title is How does one use error validation on fields that are iterated ? As an example if I have 3 fields where a team has to enter a score, I want to ensure that the only values that are entered beside each field is a number. If any of those fields have other than a number I want the error to appear only beside that particular field. Is this something that can be done with error validation ? I am looking around for examples but most examples are quite dated and I am trying to use the best things available to me. thanks in advance. Adam
Re: Textfield problem with pulling value out.
I managed to get the problem working, unfortunately that fix is by doing something that is against best practices (if I understand them correctly). To get this to work what I ended up doing was pulling the results from the search and putting that in the reset of the resultsAction. I am pretty certain your question about the setting the value on the set and not the get hit the nail on the head. I will work on the suggestions that you made and see what progress I can make. Thanks again so much for all the time and effort. On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote: It's more likely that I don't understand. This is my first struts project and I am learning as I go. Here is all of the getters/setters that I have so far. It is quite possible that I am missing some, but the previous page that I created that works used only those listed, and it works fine. The main difference being that the working one only has 1 form on the page, and that I use the reset method to pre-populate the page (which I have since learned is bad, but I haven't gotten back to fixing it). public int getNumProducts() { return numProducts; } public void setNumProducts(int numProducts) { this.numProducts = numProducts; } public int getNumProducts(int index) { if(this.results== null) { this.results = new ArrayList(); } while(index >= this.results.size() +1) { this.results.add(new Product()); } Product p = (Product) results.get(index); return p.getNumProducts(); } On 10/19/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote: > > On 10/20/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > Getter and setter methods for ? (Sorry if it should be obvious but I > want > > to clarify as it isn't obvious to me) > > > for numProducts indexed property. And i dont understand why are you > populating blank values in the getter methods..I mean you should be > doing > that in your setter methods..something like > > public void setNumProducts(int index,String val) { > while(index <= results.size()) { > results.add(new Product()); > } > Product p = (Product)results.get(index); > p.setNumProducts(val); > } > maybe i dont understnad the context of your problem properly, but this > what > i do with indexed properties. > > As far the error message here is what I recieve: > > > > javax.servlet.ServletException: BeanUtils.populate > > org.apache.struts.util.RequestUtils.populate(RequestUtils.java > > :495) > > org.apache.struts.action.RequestProcessor.processPopulate( > > RequestProcessor.java:816) > > org.apache.struts.action.RequestProcessor.process( > > RequestProcessor.java :203) > > org.apache.struts.action.ActionServlet.process( > ActionServlet.java > > :1196) > > org.apache.struts.action.ActionServlet.doPost( > ActionServlet.java > > :432) > > javax.servlet.http.HttpServlet.service (HttpServlet.java:727) > > javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > > com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) > > com.sun.enterprise.web.VirtualServerPipeline.invoke ( > > VirtualServerPipeline.java:120) > > org.apache.coyote.tomcat5.CoyoteAdapter.service( > CoyoteAdapter.java > > :231) > > > > com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter ( > > ProcessorTask.java:667) > > > > > com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked > ( > > ProcessorTask.java:574) > > com.sun.enterprise.web.connector.grizzly.ProcessorTask.process( > > ProcessorTask.java:844) > > > > com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask > ( > > ReadTask.java:287) > > com.sun.enterprise.web.connector.grizzly.ReadTask.doTask ( > > ReadTask.java:212) > > com.sun.enterprise.web.connector.grizzly.TaskBase.run( > > TaskBase.java:252) > > com.sun.enterprise.web.connector.grizzly.WorkerThread.run( > > WorkerThread.java :75) > > > > *root cause* > > > > java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 > > java.util.ArrayList.RangeCheck(ArrayList.java:546) > > java.util.ArrayList.get(ArrayList.java :321) > > > org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty( > > PropertyUtilsBean.java:433) > > > org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty( > > PropertyUtilsBean.java :340) > > > org.apache.commons.beanutils.PropertyU
Re: Textfield problem with pulling value out.
It's more likely that I don't understand. This is my first struts project and I am learning as I go. Here is all of the getters/setters that I have so far. It is quite possible that I am missing some, but the previous page that I created that works used only those listed, and it works fine. The main difference being that the working one only has 1 form on the page, and that I use the reset method to pre-populate the page (which I have since learned is bad, but I haven't gotten back to fixing it). public int getNumProducts() { return numProducts; } public void setNumProducts(int numProducts) { this.numProducts = numProducts; } public int getNumProducts(int index) { if(this.results== null) { this.results = new ArrayList(); } while(index >= this.results.size() +1) { this.results.add(new Product()); } Product p = (Product) results.get(index); return p.getNumProducts(); } On 10/19/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote: On 10/20/06, Adam K <[EMAIL PROTECTED]> wrote: > > Getter and setter methods for ? (Sorry if it should be obvious but I want > to clarify as it isn't obvious to me) for numProducts indexed property. And i dont understand why are you populating blank values in the getter methods..I mean you should be doing that in your setter methods..something like public void setNumProducts(int index,String val) { while(index <= results.size()) { results.add(new Product()); } Product p = (Product)results.get(index); p.setNumProducts(val); } maybe i dont understnad the context of your problem properly, but this what i do with indexed properties. As far the error message here is what I recieve: > > javax.servlet.ServletException: BeanUtils.populate > org.apache.struts.util.RequestUtils.populate(RequestUtils.java > :495) > org.apache.struts.action.RequestProcessor.processPopulate( > RequestProcessor.java:816) > org.apache.struts.action.RequestProcessor.process( > RequestProcessor.java:203) > org.apache.struts.action.ActionServlet.process( ActionServlet.java > :1196) > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java > :432) > javax.servlet.http.HttpServlet.service(HttpServlet.java:727) > javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) > com.sun.enterprise.web.VirtualServerPipeline.invoke( > VirtualServerPipeline.java:120) > org.apache.coyote.tomcat5.CoyoteAdapter.service( CoyoteAdapter.java > :231) > > com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter( > ProcessorTask.java:667) > > com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked ( > ProcessorTask.java:574) > com.sun.enterprise.web.connector.grizzly.ProcessorTask.process( > ProcessorTask.java:844) > > com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask( > ReadTask.java:287) > com.sun.enterprise.web.connector.grizzly.ReadTask.doTask( > ReadTask.java:212) > com.sun.enterprise.web.connector.grizzly.TaskBase.run( > TaskBase.java:252) > com.sun.enterprise.web.connector.grizzly.WorkerThread.run( > WorkerThread.java:75) > > *root cause* > > java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 > java.util.ArrayList.RangeCheck(ArrayList.java:546) > java.util.ArrayList.get(ArrayList.java:321) > org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty( > PropertyUtilsBean.java:433) > org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty( > PropertyUtilsBean.java:340) > org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty ( > PropertyUtilsBean.java:684) > org.apache.commons.beanutils.PropertyUtilsBean.getProperty( > PropertyUtilsBean.java:715) > org.apache.commons.beanutils.BeanUtilsBean.setProperty( > BeanUtilsBean.java:884) > org.apache.commons.beanutils.BeanUtilsBean.populate( > BeanUtilsBean.java:811) > org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java > :298) > org.apache.struts.util.RequestUtils.populate(RequestUtils.java > :493) > org.apache.struts.action.RequestProcessor.processPopulate( > RequestProcessor.java:816) > org.apache.struts.action.RequestProcessor.process( > RequestProcessor.java:203) > org.apache.struts.action.ActionServlet.process( ActionServlet.java > :1196) > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java > :432) > javax.servlet.http.HttpServlet.service(HttpServlet.java:727) > javax.servlet.http.HttpServlet.servic
Re: Textfield problem with pulling value out.
Getter and setter methods for ? (Sorry if it should be obvious but I want to clarify as it isn't obvious to me) As far the error message here is what I recieve: javax.servlet.ServletException: BeanUtils.populate org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) javax.servlet.http.HttpServlet.service(HttpServlet.java:820) com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231) com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667) com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574) com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844) com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287) com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212) com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252) com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75) *root cause* java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 java.util.ArrayList.RangeCheck(ArrayList.java:546) java.util.ArrayList.get(ArrayList.java:321) org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:433) org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:340) org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:684) org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715) org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:884) org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811) org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298) org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493) org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) javax.servlet.http.HttpServlet.service(HttpServlet.java:820) com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73) com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231) com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667) com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574) com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844) com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287) com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212) com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252) com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Re: Textfield problem with pulling value out.
One other thing I just realized that I should include is the fact that all of my forms are request based, which doesn't allow me to include the form information from one to the next, so to get around that (for more testing) I have included the array in a Session variable so that I can pull it out in the second action. Again thanks for all thoughts/ideas/suggestions On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote: If this is a bad technique I would be more than happy to change it to a more standard technique. Any suggestions on how to improve my code are always welcome. thanks for the suggestions thus far. Adam On 10/19/06, Chris Pratt <[EMAIL PROTECTED] > wrote: > > I don't think I've ever seen that technique before, but you have to > remember > that size() is 1 based and index (or get(index) ) is 0 based. So when > someone calls getNumProducts(5), your while loop fills in indexes 0, 1, > 2, > 3, and 4 (because then index and this.results.size() are both 5), then > you > proceed to ask for results.get(5), which doesn't exist. You should be > able > to change your while list to something like: > > while(index >= this.results.size() + 1) { > this.results.add(new Product()); > } > > (*Chris*) > > On 10/19/06, Adam K < [EMAIL PROTECTED]> wrote: > > > > Here are the 2 get methods that I have. > > > > thanks again for all the help. > > > > > > public int getNumProducts() { > > return numProducts; > > } > > > > > > public int getNumProducts(int index) > > { > > if(this.results== null) > > { > > this.results = new ArrayList(); > > } > > while(index >= this.results.size()) > > { > > this.results.add(new Product()); > > } > > > > Product p = (Product) results.get(index); > > return p.getNumProducts(); > > } > > > > On 10/19/06, Puneet Lakhina < [EMAIL PROTECTED]> wrote: > > > > > > On 10/19/06, Adam K < [EMAIL PROTECTED]> wrote: > > > > > > > > Hi all I have been working on this probelm for the past couple of > > days, > > > > and > > > > don't seem to be making any progress on it. I am fairly certain > it is > > a > > > > problem with my understanding of struts, and as such it makes it > quite > > > > difficult for me to solve the problem myself. > > > > I am trying to use a textfield and pull values from it. The > following > > > > explains the scenario. User clicks on a page, page loads with a > form > > > that > > > > has a textfield. User enters search criteria and submits > form. This > > > > works > > > > fine. Page returns with the search form and textfield, as well as > a > > > > second > > > > form that displays the results of the search. This also works > > > fine. The > > > > user then goes through the results filling in numbers for each > result > > > > indicating how many of each they would like to order and then > submit > > the > > > > form. This is where the problem results. I end up gettting an > error > > > from > > > > the page anytime I submit the form where there is 1 or more > results. > > > > Submitting with no results works fine and the page loads > correctly. > > > > Submitting with 1 result errors out with > > > > > > > > java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 > > > > > > > > Submitting with 10 results errors out with: > > > > java.lang.IndexOutOfBoundsException: Index: 2, Size: 0 > > > > > > > > Submitting with 100 results errors with : > > > > java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 > > > > > > > > Submitting with 200 results errors with : > > > > java.lang.IndexOutOfBoundsException: Index: 155, Size: 0 > > > > > > > > The number seems to be random (I am guessing it is how far into > the > > > > form it gets before the error is encountered) > > > > > > > > Any help on this would be much appreciated. > > > > I am including all the information that I believe to be important > but > > > > would have no problem including more. > > > > > > > > In the jsp form there is: > > > > > > > > > > > > > > > >
Re: Textfield problem with pulling value out.
If this is a bad technique I would be more than happy to change it to a more standard technique. Any suggestions on how to improve my code are always welcome. thanks for the suggestions thus far. Adam On 10/19/06, Chris Pratt <[EMAIL PROTECTED]> wrote: I don't think I've ever seen that technique before, but you have to remember that size() is 1 based and index (or get(index) ) is 0 based. So when someone calls getNumProducts(5), your while loop fills in indexes 0, 1, 2, 3, and 4 (because then index and this.results.size() are both 5), then you proceed to ask for results.get(5), which doesn't exist. You should be able to change your while list to something like: while(index >= this.results.size() + 1) { this.results.add(new Product()); } (*Chris*) On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote: > > Here are the 2 get methods that I have. > > thanks again for all the help. > > > public int getNumProducts() { > return numProducts; > } > > > public int getNumProducts(int index) > { > if(this.results== null) > { > this.results = new ArrayList(); > } > while(index >= this.results.size()) > { > this.results.add(new Product()); > } > > Product p = (Product) results.get(index); > return p.getNumProducts(); > } > > On 10/19/06, Puneet Lakhina < [EMAIL PROTECTED]> wrote: > > > > On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > > > Hi all I have been working on this probelm for the past couple of > days, > > > and > > > don't seem to be making any progress on it. I am fairly certain it is > a > > > problem with my understanding of struts, and as such it makes it quite > > > difficult for me to solve the problem myself. > > > I am trying to use a textfield and pull values from it. The following > > > explains the scenario. User clicks on a page, page loads with a form > > that > > > has a textfield. User enters search criteria and submits form. This > > > works > > > fine. Page returns with the search form and textfield, as well as a > > > second > > > form that displays the results of the search. This also works > > fine. The > > > user then goes through the results filling in numbers for each result > > > indicating how many of each they would like to order and then submit > the > > > form. This is where the problem results. I end up gettting an error > > from > > > the page anytime I submit the form where there is 1 or more results. > > > Submitting with no results works fine and the page loads correctly. > > > Submitting with 1 result errors out with > > > > > > java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 > > > > > > Submitting with 10 results errors out with: > > > java.lang.IndexOutOfBoundsException: Index: 2, Size: 0 > > > > > > Submitting with 100 results errors with : > > > java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 > > > > > > Submitting with 200 results errors with : > > > java.lang.IndexOutOfBoundsException: Index: 155, Size: 0 > > > > > > The number seems to be random (I am guessing it is how far into the > > > form it gets before the error is encountered) > > > > > > Any help on this would be much appreciated. > > > I am including all the information that I believe to be important but > > > would have no problem including more. > > > > > > In the jsp form there is: > > > > > > > > > > > > > > cellpadding="0" cellspacing="0"> > > > > > > > > > > cellspacing="1" > > > cellpadding="1" width="100%" > > > > > > >> > property="searchString" size="30" > > > maxlength="30"/> > > > > > > > > Search > > > > > > > colspan="2"> > > > > > > > > > > > > > > > > > > > > > > > >
Re: Textfield problem with pulling value out.
Here are the 2 get methods that I have. thanks again for all the help. public int getNumProducts() { return numProducts; } public int getNumProducts(int index) { if(this.results== null) { this.results = new ArrayList(); } while(index >= this.results.size()) { this.results.add(new Product()); } Product p = (Product) results.get(index); return p.getNumProducts(); } On 10/19/06, Puneet Lakhina <[EMAIL PROTECTED]> wrote: On 10/19/06, Adam K <[EMAIL PROTECTED]> wrote: > > Hi all I have been working on this probelm for the past couple of days, > and > don't seem to be making any progress on it. I am fairly certain it is a > problem with my understanding of struts, and as such it makes it quite > difficult for me to solve the problem myself. > I am trying to use a textfield and pull values from it. The following > explains the scenario. User clicks on a page, page loads with a form that > has a textfield. User enters search criteria and submits form. This > works > fine. Page returns with the search form and textfield, as well as a > second > form that displays the results of the search. This also works fine. The > user then goes through the results filling in numbers for each result > indicating how many of each they would like to order and then submit the > form. This is where the problem results. I end up gettting an error from > the page anytime I submit the form where there is 1 or more results. > Submitting with no results works fine and the page loads correctly. > Submitting with 1 result errors out with > > java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 > > Submitting with 10 results errors out with: > java.lang.IndexOutOfBoundsException: Index: 2, Size: 0 > > Submitting with 100 results errors with : > java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 > > Submitting with 200 results errors with : > java.lang.IndexOutOfBoundsException: Index: 155, Size: 0 > > The number seems to be random (I am guessing it is how far into the > form it gets before the error is encountered) > > Any help on this would be much appreciated. > I am including all the information that I believe to be important but > would have no problem including more. > > In the jsp form there is: > > > > cellpadding="0" cellspacing="0"> > > > cellpadding="1" width="100%" > > >property="searchString" size="30" > maxlength="30"/> > > Search > > > > > > > > > > > > Add To Order > > > Product > Product Desc > Quantity > > > > id="results"> > > /> > /> > indexed="true" /> post the getter method for the numProducts. that might be causing the problem. > > > > > > NO RESULTS > > > > > In the action (this action is only for the search results): > public ActionForward execute(ActionMapping mapping, ActionForm > form, > HttpServletRequest request, HttpServletResponse response) throws > Exception > { > SkuSearchForm skuform = (SkuSearchForm) form; > HttpSession session = request.getSession(); > User user = new User(); > Order order = new Order(); > ArrayList products = new ArrayList(); > > ArrayList results = new ArrayList(); > user = (User)session.getAttribute("User"); > order = user.getOrder(user.getCurrOrder()); > products = order.getProducts(); > int number = 0; > int count = 0; > > Iterator iter = results.iterator(); > //there is nothing happening in here as there is no results for some > reason. > while(iter.hasNext()) > { > Product p = (Product) iter.next(); >
Textfield problem with pulling value out.
Hi all I have been working on this probelm for the past couple of days, and don't seem to be making any progress on it. I am fairly certain it is a problem with my understanding of struts, and as such it makes it quite difficult for me to solve the problem myself. I am trying to use a textfield and pull values from it. The following explains the scenario. User clicks on a page, page loads with a form that has a textfield. User enters search criteria and submits form. This works fine. Page returns with the search form and textfield, as well as a second form that displays the results of the search. This also works fine. The user then goes through the results filling in numbers for each result indicating how many of each they would like to order and then submit the form. This is where the problem results. I end up gettting an error from the page anytime I submit the form where there is 1 or more results. Submitting with no results works fine and the page loads correctly. Submitting with 1 result errors out with java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 Submitting with 10 results errors out with: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0 Submitting with 100 results errors with : java.lang.IndexOutOfBoundsException: Index: 6, Size: 0 Submitting with 200 results errors with : java.lang.IndexOutOfBoundsException: Index: 155, Size: 0 The number seems to be random (I am guessing it is how far into the form it gets before the error is encountered) Any help on this would be much appreciated. I am including all the information that I believe to be important but would have no problem including more. In the jsp form there is: Search Add To Order Product Product Desc Quantity NO RESULTS In the action (this action is only for the search results): public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SkuSearchForm skuform = (SkuSearchForm) form; HttpSession session = request.getSession(); User user = new User(); Order order = new Order(); ArrayList products = new ArrayList(); ArrayList results = new ArrayList(); user = (User)session.getAttribute("User"); order = user.getOrder(user.getCurrOrder()); products = order.getProducts(); int number = 0; int count = 0; Iterator iter = results.iterator(); //there is nothing happening in here as there is no results for some reason. while(iter.hasNext()) { Product p = (Product) iter.next(); if(p.getNumProducts() != 0 ) { products.add(p); } count++; } { count = 1; Product p = new Product("TestProd " + count, "TestDesc"+count + " " +count, 10, new BigDecimal("101.0")); products.add(p); results.add(p); count++; } order.setProducts(products); order.setOrderId("ID12"); user.changeOrder(order, "ID12"); skuform.setResults(results); return mapping.findForward("success"); } In the form (The methods I thought were appropriate): public void setResults(ArrayList results) { this.results=results; } public ArrayList getResults() { return this.results; } public Product getResult(int index) { if(this.results == null) {
Struts textfield +Iterated list +retrieving user changed value from form.
I am working with struts 1.2.9 and trying to use the iterate function. I seem to be having a problem extracting the value from a text field inside an iterated loop. I am able to get/set values thare are being placed simply into html, but run into difficulties when working with the text fields. I am able to set the values into the text field, but unable to pull them out when in the action code of the form. The following is what I have used for code thus far: If I understand the struts wiki page that I was pointed to properly the name in the text must be the same as the id, but when I would try that I would simply receive index out of bounds errors - that was making all references to counter called results. Results is an object that is holding a product, description, and numProducts. This is in the Action portion - well it is a snippet of the entire thing. ProdSelectionForm prodSelection = (ProdSelectionForm) form; int count = 0; // take in the number of items in the order ArrayList and iterate through them while(count < order.getProductsSize() ) { Product p = null; // pull the product from the order at each position to manipulate them. p = (Product) products.get(count); // set the order amount to be what the old amount was on top of the amount that is currently on the screen p.setNumProducts(p.getNumProducts() + 1 + prodSelection.getNumProducts ()); // the below code was to test and see if the variable would change at all, with the +100 it would increment the amount on the screen by 100 everytime the action was called, so that lead me to believe that I am setting the values right. //p.getNumProducts() + 100 + prodSelection.getNumProducts() ); // set the product back into the product arraylist so it can be passed to the products.set(count, p); count++; } //set the product arrayList back into order so it can be presented on the screen. order.setProducts(products); And finally for the form I have the following relevant code: /** * @return Returns the numProduct. */ public int getNumProducts() { return numProducts; } /** * @return ReturnsnumProduct at the specified index */ public int getNumProducts(int index) { Product p = (Product) results.get(index); return p.getNumProducts(); } /** * @param numProducts The numProduct to set. */ public void setNumProducts(int numProducts) { this.numProducts = numProducts; } I seem to be able to pull the value from the page, but it won't pull the changed values - that is to say it will only pull the value that was there when the page was first presented regardless of anything that I type. Could someone point me to where I am having a brain fart. Ps. I have been made aware that I should be using JSTL, but would welcome any other critisms the list might have to offer. thanks in advance for your time on this matter.