Re: multiple form fields (I HATE CTRL-S )
yes niall, it's name of hindu god. but i am just a human ;-) pual, did it help you??? - Original Message - From: Niall Pemberton [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, June 28, 2001 8:31 PM Subject: RE: multiple form fields (I HATE CTRL-S ) Paul, 1) The reason you're getting null pointer error for the attribute indexed is because Dave's tags initialise indexed to null - you have to set it to true or false in your jsp. i.e. html:text name=parameter property=value indexed=true/ 2) You seem to be setting up your data incorrectly in your jsp Typically an action of yours would run off, get some data and load it into your ActionForm which then forward to a jsp to display/edit. I'm not sure why you've got it in your jsp, but anyway what you've done isnt right - its creating your vector BUT isntead of putting it in your actionForm, your storing it as a page scope parameter under the name ParameterList. Instead of this: pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); You should be doing something like: salesordercreateForm.setParameterList(vin); My suggestion too keep it simple, take that stuff out of your jsp and put it in the constructor of your ActionForm - then you know its always going to be present (dont have to worry about scope). Anyway as you have it at the moment youre always going to have any empty vector - so you wont see anything. i.e. something like public class SalesOrderCreateForm extends ActionForm { public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(0,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_currency,USD)); } etc. etc. 3) Rama Krishna's (isnt he a Hindu God?) put up a reply for you about Vector or Vectors (havent done that flavour myself), so if you can get that working to display your data youre half way there. Niall -Original Message- From: Paul Beer [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 03:35 To: Struts-User Subject: RE: multiple form fields (I HATE CTRL-S ) OK here's my bad code. There are two problems Im try to resollve here : 1) i cant iterate through a vector (how do i give the html tag an enumerator ???) 2) even though i rebuilt struts w/tags from husted.com i get a null pointer error for the attribute indexed i can get iterations to work with simple ine dimensional arrays, but what i really want to do is input a grid of data as a vector of vectors. so basically what is below is only a broken half the implementation i need... the other thing i need to know is how to set this data in the formBean. does this method do it : public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } first here's the errors I am trying to get around : Attribute 'indexed' not found in tag library 'null' for the tag text. I also get no results form the vector iteration below. here's the JSP : html:form { java.util.Vector vin = new java.util.Vector(); vin.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); vin.add(0,new SapValidParameter(orderitemsin_material,TEST)); vin.add(0,new SapValidParameter(orderitemsin_billdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_plant,2000)); vin.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); vin.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); vin.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); vin.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_currency,USD)); pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); } % ol logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter property=value / /logic:iterate /ol /html:form /body /html:html here's the form code : /** * The parameter list */ private Vector parameterList = new Vector(); /** * Return
RE: multiple form fields (I HATE CTRL-S )
Hi Paul. Just got in (tied up this am). Agree with everything that Niall said. Just wanted to confirm that you don't get an error when you actually BUILD Struts? ie you get the error when you try and use the tag, and check that you have copied the struts-html.tld into your directory too? Let me know if you still have probs. Dave PS Don't worry about asking the qu's - can all be quite confusing to start with!! Niall Pemberton [EMAIL PROTECTED] on 06/28/2001 11:31:28 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc:(bcc: David Hay/Lex/Lexmark) Subject: RE: multiple form fields (I HATE CTRL-S ) Paul, 1) The reason you're getting null pointer error for the attribute indexed is because Dave's tags initialise indexed to null - you have to set it to true or false in your jsp. i.e. html:text name=parameter property=value indexed=true/ 2) You seem to be setting up your data incorrectly in your jsp Typically an action of yours would run off, get some data and load it into your ActionForm which then forward to a jsp to display/edit. I'm not sure why you've got it in your jsp, but anyway what you've done isnt right - its creating your vector BUT isntead of putting it in your actionForm, your storing it as a page scope parameter under the name ParameterList. Instead of this: pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); You should be doing something like: salesordercreateForm.setParameterList(vin); My suggestion too keep it simple, take that stuff out of your jsp and put it in the constructor of your ActionForm - then you know its always going to be present (dont have to worry about scope). Anyway as you have it at the moment youre always going to have any empty vector - so you wont see anything. i.e. something like public class SalesOrderCreateForm extends ActionForm { public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(0,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_currency,USD)); } etc. etc. 3) Rama Krishna's (isnt he a Hindu God?) put up a reply for you about Vector or Vectors (havent done that flavour myself), so if you can get that working to display your data youre half way there. Niall -Original Message- From: Paul Beer [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 03:35 To: Struts-User Subject: RE: multiple form fields (I HATE CTRL-S ) OK here's my bad code. There are two problems Im try to resollve here : 1) i cant iterate through a vector (how do i give the html tag an enumerator ???) 2) even though i rebuilt struts w/tags from husted.com i get a null pointer error for the attribute indexed i can get iterations to work with simple ine dimensional arrays, but what i really want to do is input a grid of data as a vector of vectors. so basically what is below is only a broken half the implementation i need... the other thing i need to know is how to set this data in the formBean. does this method do it : public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } first here's the errors I am trying to get around : Attribute 'indexed' not found in tag library 'null' for the tag text. I also get no results form the vector iteration below. here's the JSP : html:form { java.util.Vector vin = new java.util.Vector(); vin.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); vin.add(0,new SapValidParameter(orderitemsin_material,TEST)); vin.add(0,new SapValidParameter(orderitemsin_billdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_plant,2000)); vin.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); vin.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); vin.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); vin.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_currency,USD)); pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); } % ol logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter
RE: multiple form fields (I HATE CTRL-S )
i got it all compiled. i think it wasnt compiling just becasue there were older versions of some of the java files.. versionitis. anyway, Ive got a vector iteration working, but I am still struggling getting the vector values to display in the html tag. i get a Unable to Find Method error. Is the property=value setting accessing the vector object getValue() method? This is the part that seems to be broken. thanks for any help you can give. -paul here is my code : SapValidParameter : String FieldName = new String(); String FieldValue = new String(); public SapValidParameter(String f, String v) { FieldName = f; FieldValue = v; } public String getValue() {return FieldName; } public String getName() {return FieldValue; } public String toString() {return FieldName; } } formbean: private Vector parameterList = new Vector(); public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(1,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(2,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(3,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(4,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(5,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(6,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(7,new SapValidParameter(orderitemsin_matlgroup,2000)); parameterList.add(8,new SapValidParameter(orderitemsin_purchdate,2101)); parameterList.add(9,new SapValidParameter(orderitemsin_currency,USD)); } /** * Return the list of parameters */ public Vector getParameterList() { return(this.parameterList); } public String getParameters() { return(this.parameterList.toString()); } /** * Set the list of parameters * * @param parameterList The new list */ public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } /** * Get a particular parameter from the parameterList, based on index * * @param index The index of the parameter to retrieve */ public SapValidParameter getParameter(int index) { return (SapValidParameter)parameterList.elementAt(index); } JSP: logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter property=value indexed=true / /logic:iterate -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 29, 2001 10:06 AM To: [EMAIL PROTECTED] Subject: RE: multiple form fields (I HATE CTRL-S ) Hi Paul. Just got in (tied up this am). Agree with everything that Niall said. Just wanted to confirm that you don't get an error when you actually BUILD Struts? ie you get the error when you try and use the tag, and check that you have copied the struts-html.tld into your directory too? Let me know if you still have probs. Dave PS Don't worry about asking the qu's - can all be quite confusing to start with!! Niall Pemberton [EMAIL PROTECTED] on 06/28/2001 11:31:28 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc:(bcc: David Hay/Lex/Lexmark) Subject: RE: multiple form fields (I HATE CTRL-S ) Paul, 1) The reason you're getting null pointer error for the attribute indexed is because Dave's tags initialise indexed to null - you have to set it to true or false in your jsp. i.e. html:text name=parameter property=value indexed=true/ 2) You seem to be setting up your data incorrectly in your jsp Typically an action of yours would run off, get some data and load it into your ActionForm which then forward to a jsp to display/edit. I'm not sure why you've got it in your jsp, but anyway what you've done isnt right - its creating your vector BUT isntead of putting it in your actionForm, your storing it as a page scope parameter under the name ParameterList. Instead of this: pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); You should be doing something like: salesordercreateForm.setParameterList(vin); My suggestion too keep it simple, take that stuff out of your jsp and put it in the constructor of your ActionForm - then you know its always going to be present (dont have to worry about scope). Anyway as you have it at the moment youre always going to have any empty vector - so you wont see anything. i.e. something like public class SalesOrderCreateForm extends ActionForm { public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(0,new SapValidParameter(orderitemsin_material,TEST
Re: multiple form fields (I HATE CTRL-S )
i do have the same problem. i can get to display it with bean:write but struck up when displaying in text fields. can anyone help us??? - Original Message - From: Paul Beer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 29, 2001 12:26 PM Subject: RE: multiple form fields (I HATE CTRL-S ) i got it all compiled. i think it wasnt compiling just becasue there were older versions of some of the java files.. versionitis. anyway, Ive got a vector iteration working, but I am still struggling getting the vector values to display in the html tag. i get a Unable to Find Method error. Is the property=value setting accessing the vector object getValue() method? This is the part that seems to be broken. thanks for any help you can give. -paul here is my code : SapValidParameter : String FieldName = new String(); String FieldValue = new String(); public SapValidParameter(String f, String v) { FieldName = f; FieldValue = v; } public String getValue() {return FieldName; } public String getName() {return FieldValue; } public String toString() {return FieldName; } } formbean: private Vector parameterList = new Vector(); public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(1,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(2,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(3,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(4,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(5,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(6,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(7,new SapValidParameter(orderitemsin_matlgroup,2000)); parameterList.add(8,new SapValidParameter(orderitemsin_purchdate,2101)); parameterList.add(9,new SapValidParameter(orderitemsin_currency,USD)); } /** * Return the list of parameters */ public Vector getParameterList() { return(this.parameterList); } public String getParameters() { return(this.parameterList.toString()); } /** * Set the list of parameters * * @param parameterList The new list */ public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } /** * Get a particular parameter from the parameterList, based on index * * @param index The index of the parameter to retrieve */ public SapValidParameter getParameter(int index) { return (SapValidParameter)parameterList.elementAt(index); } JSP: logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter property=value indexed=true / /logic:iterate -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 29, 2001 10:06 AM To: [EMAIL PROTECTED] Subject: RE: multiple form fields (I HATE CTRL-S ) Hi Paul. Just got in (tied up this am). Agree with everything that Niall said. Just wanted to confirm that you don't get an error when you actually BUILD Struts? ie you get the error when you try and use the tag, and check that you have copied the struts-html.tld into your directory too? Let me know if you still have probs. Dave PS Don't worry about asking the qu's - can all be quite confusing to start with!! Niall Pemberton [EMAIL PROTECTED] on 06/28/2001 11:31:28 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc:(bcc: David Hay/Lex/Lexmark) Subject: RE: multiple form fields (I HATE CTRL-S ) Paul, 1) The reason you're getting null pointer error for the attribute indexed is because Dave's tags initialise indexed to null - you have to set it to true or false in your jsp. i.e. html:text name=parameter property=value indexed=true/ 2) You seem to be setting up your data incorrectly in your jsp Typically an action of yours would run off, get some data and load it into your ActionForm which then forward to a jsp to display/edit. I'm not sure why you've got it in your jsp, but anyway what you've done isnt right - its creating your vector BUT isntead of putting it in your actionForm, your storing it as a page scope parameter under the name ParameterList. Instead of this: pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); You should be doing something like: salesordercreateForm.setParameterList(vin); My suggestion too keep it simple, take that stuff out of your jsp and put it in the constructor of your ActionForm - then you know its always going
RE: multiple form fields (I HATE CTRL-S )
Rama, Paul Hadn't tried Vector of Vectors before and this isnt a very elegant solution, but it works. Basically I resolved it by sub-classing Vector to create a VectorBean (adding getValue/setValue methods) and generating the name in the format name=grid[x].value[y].value My suggestion would be to write your own tag which generates it all automatically, so you would have to code something like: myTags:input type=text outer=grid outerIndex=rowNo inner=cell innerIndex=cellNo/ Perhaps if its just used in grid situations your tag could discover these attributes anyway - I'm not sure, havent looked into it. hope this helps Niall --- START jsp -- html:form action=/test5.do table logic:iterate id=row name=myActionForm property=grid indexId=rowNo tr logic:iterate id=cell name=row indexId=cellNo tdinput type=text value=bean:write name='cell'/ name=grid[bean:write name='rowNo'/].value[bean:write name='cellNo'/].value /td /logic:iterate /tr /logic:iterate /table html:submit/ /html:form --- END jsp -- ---START MyActionForm -- package com.amarda.hbm.main; import org.apache.struts.action.ActionForm; import java.util.Vector; public class MyActionForm extends ActionForm { private VectorBean grid = new VectorBean(); public MyActionForm() { // Create the Grid for (int i = 0; i 5; i++) { //Create a row VectorBean row = new VectorBean(); row.add(Cell (+i+, 0)); row.add(Cell (+i+, 1)); row.add(Cell (+i+, 2)); grid.add(row); } } /** * Return the grid */ public VectorBean getGrid() { return grid; } /** * Get a particular row from the grid * * @param index The index of the parameter to retrieve */ public VectorBean getGrid(int index){ return (VectorBean)grid.elementAt(index); } } --- END MyActionForm -- ---START VectorBean -- package com.amarda.hbm.main; import java.util.Vector; public class VectorBean extends Vector { private int index; public VectorBean() { super(); } public VectorBean(int init) { super(init); } public VectorBean(int init, int incr) { super(init, incr); } public Object getValue(int index) { //store the index, so that when // the setValue() method is called // ws know which element to update this.index = index; return this; } public void setValue(Object value) { this.setElementAt(value, index); } } --- END VectorBean -- -Original Message- From: Rama Krishna [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 22:02 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: multiple form fields (I HATE CTRL-S ) i do have the same problem. i can get to display it with bean:write but struck up when displaying in text fields. can anyone help us??? - Original Message - From: Paul Beer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 29, 2001 12:26 PM Subject: RE: multiple form fields (I HATE CTRL-S ) i got it all compiled. i think it wasnt compiling just becasue there were older versions of some of the java files.. versionitis. anyway, Ive got a vector iteration working, but I am still struggling getting the vector values to display in the html tag. i get a Unable to Find Method error. Is the property=value setting accessing the vector object getValue() method? This is the part that seems to be broken. thanks for any help you can give. -paul __ __ here is my code : SapValidParameter : String FieldName = new String(); String FieldValue = new String(); public SapValidParameter(String f, String v) { FieldName = f; FieldValue = v; } public String getValue() {return FieldName; } public String getName() {return FieldValue; } public String toString() {return FieldName; } } formbean: private Vector parameterList = new Vector(); public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(1,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(2,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(3,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(4,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(5,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(6,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(7,new
RE: multiple form fields (I HATE CTRL-S )
OK here's my bad code. There are two problems Im try to resollve here : 1) i cant iterate through a vector (how do i give the html tag an enumerator ???) 2) even though i rebuilt struts w/tags from husted.com i get a null pointer error for the attribute indexed i can get iterations to work with simple ine dimensional arrays, but what i really want to do is input a grid of data as a vector of vectors. so basically what is below is only a broken half the implementation i need... the other thing i need to know is how to set this data in the formBean. does this method do it : public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } first here's the errors I am trying to get around : Attribute 'indexed' not found in tag library 'null' for the tag text. I also get no results form the vector iteration below. here's the JSP : html:form { java.util.Vector vin = new java.util.Vector(); vin.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); vin.add(0,new SapValidParameter(orderitemsin_material,TEST)); vin.add(0,new SapValidParameter(orderitemsin_billdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_plant,2000)); vin.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); vin.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); vin.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); vin.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_currency,USD)); pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); } % ol logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter property=value / /logic:iterate /ol /html:form /body /html:html here's the form code : /** * The parameter list */ private Vector parameterList = new Vector(); /** * Return the list of parameters */ public Vector getParameterList() { return(this.parameterList); } public String getParameters() { return(this.parameterList.toString()); } /** * Set the list of parameters * * @param parameterList The new list */ public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } /** * Get a particular parameter from the parameterList, based on index * * @param index The index of the parameter to retrieve */ public SapValidParameter getParameter(int index) { return (SapValidParameter)parameterList.elementAt(index); } -Original Message- From: Niall Pemberton [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 28, 2001 5:40 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: multiple form fields Hey thats what this list is for - your headaches as valid as anyone elses, keep sending them until you get a result. Post all the bits of code in an email - your action form and/or bean(s) and the jsp - plus when is throwing the Null pointer exception, - in the jsp, before your page is displaying or afterwards when its trying to populate back? Off the top of my head you might be getting null pointer exceptions for a couple of reasons: 1) If its happening before your page is displayed it might be because there are nulls in your array/collection/vector - make sure its all loaded/initialised containing no nulls before you forward to your jsp page. 2) If its happening after you submit your form back (using Daves tags) then check the scope of your form - if its in session scope you should be OK, if its in request scope you will need to do something clever to set it up again. Struts effectively does a getX(index).setY(value) call Anyway, if you post your code it'll be easier to see whats happening. You are using Dave's modified tags from husted.com? Niall -Original Message- From: Paul Beer [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 00:56 To: [EMAIL PROTECTED] Subject: RE: multiple form fields Im still having problems getting this. I just started using struts so please bear with me here. But can someone please email me something similar to the logic-iterate example that cmoes with the example-taglibs demo ? I am getting null pointer errors and I dont if it is my struts distribution or my own inability to grock this i will try not to toxify this list with any more of this its just that if I cant model a formbean w/a grid of data struts is worthless to me, because my whole world is executing functions w/import tables. -paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 28, 2001 1:54 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: multiple form fields Paul, a concrete example using modified tag: jsp:
RE: multiple form fields (I HATE CTRL-S )
Paul, 1) The reason you're getting null pointer error for the attribute indexed is because Dave's tags initialise indexed to null - you have to set it to true or false in your jsp. i.e. html:text name=parameter property=value indexed=true/ 2) You seem to be setting up your data incorrectly in your jsp Typically an action of yours would run off, get some data and load it into your ActionForm which then forward to a jsp to display/edit. I'm not sure why you've got it in your jsp, but anyway what you've done isnt right - its creating your vector BUT isntead of putting it in your actionForm, your storing it as a page scope parameter under the name ParameterList. Instead of this: pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); You should be doing something like: salesordercreateForm.setParameterList(vin); My suggestion too keep it simple, take that stuff out of your jsp and put it in the constructor of your ActionForm - then you know its always going to be present (dont have to worry about scope). Anyway as you have it at the moment youre always going to have any empty vector - so you wont see anything. i.e. something like public class SalesOrderCreateForm extends ActionForm { public SalesOrderCreateForm() { parameterList.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); parameterList.add(0,new SapValidParameter(orderitemsin_material,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_billdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_plant,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); parameterList.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); parameterList.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); parameterList.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); parameterList.add(0,new SapValidParameter(orderitemsin_currency,USD)); } etc. etc. 3) Rama Krishna's (isnt he a Hindu God?) put up a reply for you about Vector or Vectors (havent done that flavour myself), so if you can get that working to display your data youre half way there. Niall -Original Message- From: Paul Beer [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 03:35 To: Struts-User Subject: RE: multiple form fields (I HATE CTRL-S ) OK here's my bad code. There are two problems Im try to resollve here : 1) i cant iterate through a vector (how do i give the html tag an enumerator ???) 2) even though i rebuilt struts w/tags from husted.com i get a null pointer error for the attribute indexed i can get iterations to work with simple ine dimensional arrays, but what i really want to do is input a grid of data as a vector of vectors. so basically what is below is only a broken half the implementation i need... the other thing i need to know is how to set this data in the formBean. does this method do it : public void setParameterList(Vector parameterList) { this.parameterList = parameterList; } first here's the errors I am trying to get around : Attribute 'indexed' not found in tag library 'null' for the tag text. I also get no results form the vector iteration below. here's the JSP : html:form { java.util.Vector vin = new java.util.Vector(); vin.add(0,new SapValidParameter(orderitemsin_itmnumber,00010)); vin.add(0,new SapValidParameter(orderitemsin_material,TEST)); vin.add(0,new SapValidParameter(orderitemsin_billdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_plant,2000)); vin.add(0,new SapValidParameter(orderitemsin_targetqty,1000)); vin.add(0,new SapValidParameter(orderitemsin_shorttext,TEST)); vin.add(0,new SapValidParameter(orderitemsin_reqdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_matlgroup,2000)); vin.add(0,new SapValidParameter(orderitemsin_purchdate,2101)); vin.add(0,new SapValidParameter(orderitemsin_currency,USD)); pageContext.setAttribute(ParameterList, vin, PageContext.PAGE_SCOPE); } % ol logic:iterate id=parameter name=salesordercreateForm property=parameterList html:text name=parameter property=value / /logic:iterate /ol /html:form /body /html:html here's the form code : /** * The parameter list */ private Vector parameterList = new Vector(); /** * Return the list of parameters */ public Vector getParameterList() { return(this.parameterList); } public String getParameters() { return(this.parameterList.toString()); } /** * Set the list of parameters * * @param parameterList The new list */ public void setParameterList(Vector parameterList) { this.parameterList = parameterList