You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Ashamalla <ma...@vistaxtreme.com> on 2001/12/04 03:42:07 UTC

Indexed tags

Hi All!

I apologize if this question has been asked before.  I'm trying to implement
indexed tags and I can't figure out where the values are being set (ie -
where should me setters be and what should they look like).  The form
displays the prompts and values perfectly, but when I submit it the new
values don't seem to be posting to the formbean.  I've read as many posts
and archives as I could find, but still don't see what I'm doing wrong.  One
archived post stated "... this will be translated by struts into a call
ParametersForm.getParameter(0).setValue(value) ...".  The setValue method in
EmploymentInfoField (see below) is not being called, though.  No errors are
being generated either (when I submit the form).  The HTML source that is
produced looks like this: <input type="text"
name="EmploymentInfoField[0].value" size="30" value="East Coast">

BTW - I'm using Struts nightly build from 11/28/2001 and Tomcat 3.2.2

I've seen many posts that didn't have enough information/code for people to
help, so I'm including as much as possible.  Sorry for the long post.  Thank
you in advance!

****************************************************************************
***********
JSP Code:

       <logic:iterate id="EmploymentInfoField" name="EmploymentInfoForm"
property="employmentInfoFieldList"
type="com.mydomain.form.EmploymentInfoField">
        <tr>
          <td width="41">&nbsp;</td>
              <td width="112">
                <div class="formLabel" align="right"><bean:message
name="EmploymentInfoField" property="labelKey"/></div>
              </td>
              <td width="168">
                <div align="left">
                  <html:text name="EmploymentInfoField" property="value"
indexed="true" size="30"/>
                  </div>
              </td>
        </tr>
        </logic:iterate>
****************************************************************************
***********
****************************************************************************
***********
EmploymentInfoForm:

public class EmploymentInfoForm extends ActionForm {

private Vector employmentInfoFieldList = new Vector();

...

    public EmploymentInfoField getEmploymentInfoField(int index) {
        return (EmploymentInfoField) employmentInfoFieldList.get(index);
    }

    public Vector getEmploymentInfoFieldList() {
        return employmentInfoFieldList;
    }

    private void addEmploymentInfoField(String dbFieldName,
                                        int dataType,
                                        String labelKey,
                                        String value) {
        EmploymentInfoField eField;

        eField = new EmploymentInfoField();
        eField.setDbFieldName(dbFieldName);
        eField.setDataType(dataType);
        eField.setLabelKey(labelKey);
        eField.initValue(value);
        employmentInfoFieldList.add(eField);
    }
}
****************************************************************************
***********
****************************************************************************
***********
EmploymentInfoField:

public class EmploymentInfoField {

private int dataType;
private String dbFieldName = null;
private String labelKey = null;
private String value = null;
private boolean valueChanged = false;

    /**
     * Return the dataType
     *
     * @return the dataType
     */
    public int getDataType() {
        return dataType;
    }

    /**
     * Set the dataType.
     *
     * @param dataType The new dataType
     */
    public void setDataType(int dataType) {
      this.dataType = dataType;
    }

    /**
     * Return the dbFieldName
     *
     * @return the dbFieldName
     */
    public String getDbFieldName() {
        return dbFieldName;
    }

    /**
     * Set the dbFieldName.
     *
     * @param dbFieldName The new dbFieldName
     */
    public void setDbFieldName(String dbFieldName) {
      this.dbFieldName = dbFieldName;
    }

    /**
     * Return the labelKey
     *
     * @return the labelKey
     */
    public String getLabelKey() {
        return labelKey;
    }

    /**
     * Set the labelKey.
     *
     * @param labelKey The new labelKey
     */
    public void setLabelKey(String labelKey) {
      this.labelKey = labelKey;
    }

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

    /**
     * Initialize the value.
     *
     * @param value The new value
     */
    public void initValue(String value) {
      this.value = value;
    }

    /**
     * Set the value.
     *
     * @param value The new value
     */
    public void setValue(String value) {
      if(value.equals(this.value)) {
        valueChanged = false;
      } else {
        valueChanged = true;
      }
      this.value = value;
    }

    /**
     * Return whether or not value has changed.
     *
     * @return String
     */
    public boolean getValueHasChanged() {
      return valueChanged;
    }
}
****************************************************************************
***********

Thank You,


Mike Ashamalla, CEBS
VistaXtreme
mashamalla@vistaxtreme.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Indexed tags & iterate tag problems

Posted by Mike Ashamalla <ma...@vistaxtreme.com>.
Anyone know the answer to this???  It seems that there are two of us with
exactly the same problem (see "iterate tag problems (sorry !!)" from Eddie
Fung [iggster@netspace.net.au]).

Bottom line: When using indexed tags inside an iterate tag, the setters
don't seem to be setting the new values.

If this has already been answered elsewhere, please just point us in the
right direction. :)

Thank You,


Mike Ashamalla, CEBS
VistaXtreme
mashamalla@vistaxtreme.com

-----Original Message-----
From: Mike Ashamalla [mailto:mashamalla@vistaxtreme.com]
Sent: Monday, December 03, 2001 6:42 PM
To: Struts-User
Subject: Indexed tags


Hi All!

I apologize if this question has been asked before.  I'm trying to implement
indexed tags and I can't figure out where the values are being set (ie -
where should me setters be and what should they look like).  The form
displays the prompts and values perfectly, but when I submit it the new
values don't seem to be posting to the formbean.  I've read as many posts
and archives as I could find, but still don't see what I'm doing wrong.  One
archived post stated "... this will be translated by struts into a call
ParametersForm.getParameter(0).setValue(value) ...".  The setValue method in
EmploymentInfoField (see below) is not being called, though.  No errors are
being generated either (when I submit the form).  The HTML source that is
produced looks like this: <input type="text"
name="EmploymentInfoField[0].value" size="30" value="East Coast">

BTW - I'm using Struts nightly build from 11/28/2001 and Tomcat 3.2.2

I've seen many posts that didn't have enough information/code for people to
help, so I'm including as much as possible.  Sorry for the long post.  Thank
you in advance!

****************************************************************************
***********
JSP Code:

       <logic:iterate id="EmploymentInfoField" name="EmploymentInfoForm"
property="employmentInfoFieldList"
type="com.mydomain.form.EmploymentInfoField">
        <tr>
          <td width="41">&nbsp;</td>
              <td width="112">
                <div class="formLabel" align="right"><bean:message
name="EmploymentInfoField" property="labelKey"/></div>
              </td>
              <td width="168">
                <div align="left">
                  <html:text name="EmploymentInfoField" property="value"
indexed="true" size="30"/>
                  </div>
              </td>
        </tr>
        </logic:iterate>
****************************************************************************
***********
****************************************************************************
***********
EmploymentInfoForm:

public class EmploymentInfoForm extends ActionForm {

private Vector employmentInfoFieldList = new Vector();

...

    public EmploymentInfoField getEmploymentInfoField(int index) {
        return (EmploymentInfoField) employmentInfoFieldList.get(index);
    }

    public Vector getEmploymentInfoFieldList() {
        return employmentInfoFieldList;
    }

    private void addEmploymentInfoField(String dbFieldName,
                                        int dataType,
                                        String labelKey,
                                        String value) {
        EmploymentInfoField eField;

        eField = new EmploymentInfoField();
        eField.setDbFieldName(dbFieldName);
        eField.setDataType(dataType);
        eField.setLabelKey(labelKey);
        eField.initValue(value);
        employmentInfoFieldList.add(eField);
    }
}
****************************************************************************
***********
****************************************************************************
***********
EmploymentInfoField:

public class EmploymentInfoField {

private int dataType;
private String dbFieldName = null;
private String labelKey = null;
private String value = null;
private boolean valueChanged = false;

    /**
     * Return the dataType
     *
     * @return the dataType
     */
    public int getDataType() {
        return dataType;
    }

    /**
     * Set the dataType.
     *
     * @param dataType The new dataType
     */
    public void setDataType(int dataType) {
      this.dataType = dataType;
    }

    /**
     * Return the dbFieldName
     *
     * @return the dbFieldName
     */
    public String getDbFieldName() {
        return dbFieldName;
    }

    /**
     * Set the dbFieldName.
     *
     * @param dbFieldName The new dbFieldName
     */
    public void setDbFieldName(String dbFieldName) {
      this.dbFieldName = dbFieldName;
    }

    /**
     * Return the labelKey
     *
     * @return the labelKey
     */
    public String getLabelKey() {
        return labelKey;
    }

    /**
     * Set the labelKey.
     *
     * @param labelKey The new labelKey
     */
    public void setLabelKey(String labelKey) {
      this.labelKey = labelKey;
    }

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

    /**
     * Initialize the value.
     *
     * @param value The new value
     */
    public void initValue(String value) {
      this.value = value;
    }

    /**
     * Set the value.
     *
     * @param value The new value
     */
    public void setValue(String value) {
      if(value.equals(this.value)) {
        valueChanged = false;
      } else {
        valueChanged = true;
      }
      this.value = value;
    }

    /**
     * Return whether or not value has changed.
     *
     * @return String
     */
    public boolean getValueHasChanged() {
      return valueChanged;
    }
}
****************************************************************************
***********

Thank You,


Mike Ashamalla, CEBS
VistaXtreme
mashamalla@vistaxtreme.com


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>