The problem is that you end up having two identically named methods that return 
different types.  How is the compiler supposed to know which one to use?  I had this 
same problem myself for a while, because you are right that is what seems to follow 
JavaBean specs.  But your solution is exactly what you should do, you are still 
following spec because you do have a getter method with the correct name.  You just 
also have an additional getter method to return one within the List.  I think this 
answers your question.
 
:)

Richard Mixon <[EMAIL PROTECTED]> wrote: 
First, sorry for the long posting - it shorter than a few, but not many :).

I've read a number of very good postings on the list on how to handle
indexed properties using the "having a bit of a problem determining what the 
corresponding getter/setter
names should be.

The problem is naming of the getter for my list of line items. At first I
had the following signatures

// First to get and set the entire list
public List getCurrLineItems() ...
public void setCurrLineItems(List lineItems) ...

// Next to get and set individual indexed items in the list
public LineItem getCurrLineItems(int liDex) ...
public void setCurrLineItems(int liDex, LineItem lineItem) ...

With the indexed getter/setters as above, it does not work. However, if I
name them differently from the List getter/setters they work (for example
names then getCurrentLineItems and setCurrentLineItems instead of
getCurrLineItems and setCurrLineItems). This appears to be contrary to all
of the examples I can find and the JavaBeans spec. Before proceeding I want
to clear this up.

With the matching names for indexed properties I could not get my JSP page
to see the line items. I tried the "logic:iterate", "nested:iterate" and
"logic-el:iterate" variations of the Struts iterate tag. I also tried using
a JSTL "


Existing Line Items



Delete
    



key="formLineItemsForm.status"/>
Act  Inact

property="currLineItems" indexId="mpDex">

property="deleteXMP[${mpDex}]" value="true" title="Check to delete and press
Change"/>
 
property="name" size="24" maxlength="24" indexed="true"/>

indexed="true">
labelProperty="name"/>


size="1" maxlength="2" indexed="true" />

value="1" indexed="true"/> property="status_id" value="2" indexed="true"/>

indexed="true"/>
indexed="true"/>
indexed="true"/>








...
JSP - fragment - END


FormBean - BEGIN
public class OrderLineForm extends com.ltoj.webapp.form.BaseForm implements
java.io.Serializable {

private OrderForm base = new OrderForm();
private List deleteXMP = new ArrayList();
private List currLineItems = new ArrayList();
private List newLineItems = new ArrayList(1);

public OrderForm getBase() { return base; }

public void setBase(OrderForm subject) { this.base = subject; }

/**
* Flags, set if corresponding existing line item should be deleted.
*/
public List getDeleteXMP() { return deleteXMP; }
public String getDeleteXMP(int mpDex) { return
(String)this.deleteXMP.get(mpDex); }

public void setDeleteXMP(List deleteXMP) { this.deleteXMP = deleteXMP; }
public void setDeleteXMP(int mpDex, String deleteXMP) {
this.deleteXMP.add(deleteXMP); }

public List getCurrLineItems() { return this.currLineItems; }
public LineItemsForm getCurrMeasurementParms(int mpDex) { return
(LineItemsForm)this.currLineItems.get(mpDex); }

public void setCurrLineItems( List currLineItems ) { this.currLineItems
= currLineItems; }
public void setCurrMeasurementParms( int mpDex, LineItemsForm
currLineItem ) { this.currLineItems.add(currLineItem); }

public List getNewLineItems() { return this.newLineItems; }
public LineItemsForm getNewMeasurementParms(int mpDex) { return
(LineItemsForm)this.newLineItems.get(mpDex); }

public void setNewLineItems( List newLineItems ) { this.newLineItems =
newLineItems; }
public void setNewMeasurementParms( int mpDex, LineItemsForm
newLineItem ) { this.newLineItems.add(newLineItem); }

public void reset(ActionMapping mapping, HttpServletRequest request) {
base = new OrderForm();
deleteXMP = new ArrayList();
currLineItems = new ArrayList();
newLineItems = new ArrayList(1);
}
}
FormBean - END



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




---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Reply via email to