I should also mention that I populate the ArrayList before displaying.
Everything displays woth a problem. I cannot see this being an issue but
maybe internally there is a conflict between the List and the PropertyItem
array. Hey, I'm running out of ideas. Am I missing the bleeding obvious
here?

-----Original Message-----
From: RALPH ROPER [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 16 December 2003 4:06 PM
To: Struts Users Mailing List (E-mail)
Subject: FW: cannot populate input field within iterate tag


Sue,

no go. I have followed the keyboardmonkey example (see
http://www.keyboardmonkey.com/pilotlight/next/Tutorial_partTwo.jsp?content=y
esplease). I am now encountering the same issue as a previous post
(http://www.mail-archive.com/[EMAIL PROTECTED]/msg88040.html)
where I receive a BeanUtils.populate error message. The stack trace is

[16/12/03 15:13:04:219 EST] 65f5ef5a WebGroup      E SRVE0026E: [Servlet
Error]-[BeanUtils.populate]: java.lang.ArrayIndexOutOfBoundsException
        at java.lang.reflect.Array.get(Native Method)
        at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
java:525)
        at
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.
java:428)
        at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:770)
        at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:80
1)
        at
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881)
        at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
<etc>

I have the following

ITSparamsPropertyEditor.jsp snippet

        <logic:notEmpty name="propertyForm" property="propertys" >
        
                <table style="margin:10px">     
                
                <nested:iterate id="lr" property="propertys" >
                
                        <bean:define id="ky" name="lr" property="key"
type="java.lang.String" />
                        <bean:define id="vl" name="lr" property="value"
type="java.lang.String" />
                        
                        <tr><td> <nested:write name="lr" property="key" />
</td>
                        <td><nested:text property="key" value="<%= vl%>"
/></td></tr>
                        </nested:iterate>
                </table>        
                &nbsp;&nbsp;&nbsp;<input type=button value="Update"
name="update" class="button"  onclick="updateProp();">  
        </logic:notEmpty>

The PropertyEditorForm is my bean that contains the propertys ArrayList.

public class PropertyEditorForm extends ActionForm {

        private String fileName;
        private List propertys = new ArrayList();
        /**
         * Returns the fileName.
         * @return String
         */
        public String getFileName() {
                return fileName;
        }

        /**
         * Sets the fileName.
         * @param fileName The fileName to set
         */
        public void setFileName(String fileName) {
                this.fileName = fileName;
        }

        public void reset(
                ActionMapping mapping,
                javax.servlet.http.HttpServletRequest request) {
                fileName = "none";
                propertys=new ArrayList();
        }

        public Object[] getPropertys()
        {
                return this.propertys.toArray();
        }
        
        public void setPropertys(Object[] newPropertys){

                for (int i = 0; i < newPropertys.length; i++){
                  propertys.add(newPropertys[i]);
                }
         }

        /**
         * @param pi
         */
        public void addProperty(PropertyItem pi) {
                propertys.add(pi);
        }
}

My PropertyItem bean is very simple.

public class PropertyItem {
        
        private String key;
        private String value;
        

        /**
         * @return
         */
        public String getKey() {
                return key;
        }

        /**
         * @return
         */
        public String getValue() {
                return value;
        }

        /**
         * @param string
         */
        public void setKey(String string) {
                key = string;
        }

        /**
         * @param string
         */
        public void setValue(String string) {
                value = string;
        }
}

Does anyone know what is going on here?

thanks,

Ralph


-----Original Message-----
From: White, Susan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 16 December 2003 2:36 AM
To: RALPH ROPER
Subject: RE: cannot populate input field within iterate tag


Or maybe name="vl"? I'm not quite sure which might work. I usually try
everything ;-)

-----Original Message-----
From: White, Susan 
Sent: Monday, December 15, 2003 10:35 AM
To: 'RALPH ROPER'
Subject: RE: cannot populate input field within iterate tag


I'm not sure this will work, but maybe you need to put in nested:text
statement name="lr" ?

-----Original Message-----
From: RALPH ROPER [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 15, 2003 2:38 AM
To: 'Struts Users Mailing List'
Subject: RE: cannot populate input field within iterate tag


OK.

I am a little bit closer thanks to an email on this list.
http://www.mail-archive.com/[EMAIL PROTECTED]/msg72240.html
It
looks like I need to use the nested tags to make it happen. After having
tried to put it together I ended up with the same error as the last post
ie
java.lang.IllegalArgumentException: No bean specified

I am trying to use a Map. After many permutations my jsp code is as
follows.
        <nested:iterate id="lr" property="propertyMap"
type="java.util.Map.Entry" >
                
                <bean:define id="ky" name="lr" property="key"
type="java.lang.String" />
                <bean:define id="vl" name="lr" property="value"
type="java.lang.String" />
                        
                <tr><td> <nested:write name="lr" property="key" />
</td><td>
                <% if (ky.endsWith("PWD") | ky.endsWith("PASSWORD")) {
%>
----->           <nested:password property="value" value="<%= vl%>" />
                <% } else { %>
----->           <nested:text property="value" value="<%= vl%>" />
                <% } %>
                 </td></tr>
        </nested:iterate>

I am trying to use the Map.Entry interface which I have seen being used.
Is
this the right approach?

I know this has been discussed a million times before but no-one has
explained a really good Map example. 

thanks,

Ralph



-----Original Message-----
From: RALPH ROPER [mailto:[EMAIL PROTECTED]
Sent: Friday, 12 December 2003 7:16 PM
To: '[EMAIL PROTECTED]'
Subject: cannot populate input field within iterate tag


hi,

I have a fairly simple request but after many attempts I am no closer to
resolving it. The problem is trying to update a property within a
logic:iterate tag. The property is a Collection of PropertyRecords that
live
on my PropertyForm bean. The PropertyRecord class contains two
properties 1)
key and 2) value. I want to update the value property that is associated
to
a key. This key/value comibination is better suited to a Map which I
tried
to getting working initially but gave up on.

The display of the screen works fine. It is when I go to update a value
and
Submit the form that it does not update the value. 

It looks like the name in the html:text tag name attribute is incorrect.
This is the only reason why I can see that the Collection does not
update
with the newly entered value.

In my 

JSP Page ITSparamsPropertyEditor.jsp

<logic:iterate id="lr" name="propertyForm" property="properties"
type="com.cuscal.settlements.redinet.helpClass.utilities.properties.Prop
erty
Record" >
                
        <bean:define id="ky" name="lr" property="key"
type="java.lang.String" />
        <bean:define id="vl" name="lr" property="value"
type="java.lang.String" />
                        
        <tr><td> <bean:write name="lr" property="key" /> </td><td>
        <% if (ky.endsWith("PWD") | ky.endsWith("PASSWORD")) { %>
                <html:password name="lr" property="propertyKey"
value="<%=
vl%>"                           indexed="true" />
        <% } else { %>
                 <html:text name="lr" property="key" value="<%= vl%>"
indexed="true" />
        <% } %>
         </td></tr>
</logic:iterate>

The PropertyEditorForm class which has the bean id propertyForm.

public class PropertyEditorForm extends ActionForm {

        private String fileName;
        private List properties;
        /**
         * Returns the fileName.
         * @return String
         */
        public String getFileName() {
                return fileName;
        }

        /**
         * Sets the fileName.
         * @param fileName The fileName to set
         */
        public void setFileName(String fileName) {
                this.fileName = fileName;
        }

        public void reset(
                ActionMapping mapping,
                javax.servlet.http.HttpServletRequest request) {
                fileName = "none";
                //      properties=null;
        }
        /**
         * @return
         */
        public List getProperties() {
                return properties;
        }

        /**
         * @param map
         */
        public void setProperties(List properties) {
                this.properties = properties;
        }

        public String getPropertyValue(int index) {
                return ((PropertyRecord)
getProperties().get(index)).getValue();
        }
        
        public void setPropertyValue(int index, String value)
        {
                this.properties.set(index, value);
        }
        
        public String getPropertyKey(int index) {
                return ((PropertyRecord)
getProperties().get(index)).getKey();
        }
        
        public void setPropertyKey(int index, String key)
        {
                this.properties.set(index, key);
        }

}


The PropertyRecord class.
public class PropertyRecord {
        
        private String key;
        private String value;
        
        /**
         * @return
         */
        public String getKey() {
                return key;
        }

        /**
         * @return
         */
        public String getValue() {
                return value;
        }

        /**
         * @param string
         */
        public void setKey(String string) {
                key = string;
        }

        /**
         * @param string
         */
        public void setValue(String string) {
                value = string;
        }

}

Example of the HTML source that is generated.

<tr><td> EXPORT_MONTHLY_FEES_PATH </td><td>
<input type="text" name="lr[49].key"
value="/oracle/redinet/data/export/monthlyfees/">
</td></tr>

Even though I change the value of this imput field it does not update in
the
Collection on the form bean.

Any help would be much appreciated as this is driving me crazy. If
anyone
knows how to do this as a Map it would be great.

thanks,

Ralph Roper
Senior Analyst/Programmer
Business Technology Services (BTS)
Credit Union Services Corporation

________________________________________________________
NOTICE
The information in this email and or any of the attachments may contain;
a. Confidential information of Credit Union Services Corporation
(Australia)
Limited (CUSCAL) or third parties; and or
b. Legally privileged information of CUSCAL or third parties; and or
c. Copyright material of CUSCAL or third parties.
If you are not an authorised recipient of this email, please contact
CUSCAL
immediately by return email or by telephone on 61-2-8299 9000 and delete
the
email from your system.
We do not accept any liability in connection with computer virus, data
corruption, interruption or any damage generally as a result of
transmission
of this email.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

________________________________________________________
NOTICE
The information in this email and or any of the attachments may contain;
a. Confidential information of Credit Union Services Corporation
(Australia) Limited (CUSCAL) or third parties; and or
b. Legally privileged information of CUSCAL or third parties; and or
c. Copyright material of CUSCAL or third parties.
If you are not an authorised recipient of this email, please contact
CUSCAL immediately by return email or by telephone on 61-2-8299 9000 and
delete the email from your system.
We do not accept any liability in connection with computer virus, data
corruption, interruption or any damage generally as a result of
transmission of this email.
________________________________________________________
NOTICE
The information in this email and or any of the attachments may contain;
a. Confidential information of Credit Union Services Corporation (Australia)
Limited (CUSCAL) or third parties; and or
b. Legally privileged information of CUSCAL or third parties; and or
c. Copyright material of CUSCAL or third parties.
If you are not an authorised recipient of this email, please contact CUSCAL
immediately by return email or by telephone on 61-2-8299 9000 and delete the
email from your system.
We do not accept any liability in connection with computer virus, data
corruption, interruption or any damage generally as a result of transmission
of this email.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

________________________________________________________
NOTICE
The information in this email and or any of the attachments may contain;
a. Confidential information of Credit Union Services Corporation (Australia) Limited 
(CUSCAL) or third parties; and or
b. Legally privileged information of CUSCAL or third parties; and or
c. Copyright material of CUSCAL or third parties.
If you are not an authorised recipient of this email, please contact CUSCAL 
immediately by return email or by telephone on 61-2-8299 9000 and delete the email 
from your system.
We do not accept any liability in connection with computer virus, data corruption, 
interruption or any damage generally as a result of transmission of this email.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to