aspose file tools*
The moose likes Struts and the fly likes want help with html:optionscollection tag... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "want help with html:optionscollection tag..." Watch "want help with html:optionscollection tag..." New topic
Author

want help with html:optionscollection tag...

sruti roy
Greenhorn

Joined: May 28, 2009
Posts: 5
hi
i am trying to implement htmlptioscollection tag....but i m little comfused...please help...i m trying to select month list....
this is my jsp page...
<html:select property="selectedItem">
<htmlptionsCollection name="createpayfixationactionForm" value="id" label="month" />
</html:select>

this is my moi.java file........

package com.myapp.struts;
public class moi {
private int id;
private String month;
public moi(){}
public moi(int id,String month){
this.id=id;
this.month=month;
}
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public String getMonth(){
return month;
}
public void setMonth(String month){
this.month=month;
}
public String getLabel(){
return this.month;
}
public int getValue(){
return this.id;
}

}
this is bean
public class create_pay_fixationActionForm extends org.apache.struts.action.ActionForm {
public String getSelectedItem() {
return selectedItem;
}

public void setSelectedItem(String selectedItem) {
this.selectedItem=selectedItem;
}}

this is my action...
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Collection mois= new ArrayList();
mois.add(new moi(1,"January"));
mois.add(new moi(2,"February"));
mois.add(new moi(3,"March"));
mois.add(new moi(4,"April"));
mois.add(new moi(5,"May"));
mois.add(new moi(6,"June"));
mois.add(new moi(7,"July"));
mois.add(new moi(8,"August"));
mois.add(new moi(9,"September"));
mois.add(new moi(10,"October"));
mois.add(new moi(11,"November"));
mois.add(new moi(12,"December"));
} }

please tell me where i m going wrong....what i have to do to make it right....
regards....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags.

Java class names, by convention, start with a capital letter, and do not contain underscroes: it's a good idea to follow those conventions to avoid confusion.

You're giving the name of a form as the collection name; that is almost certainly incorrect. You should provide an actual collection.
sruti roy
Greenhorn

Joined: May 28, 2009
Posts: 5
David Newton wrote:Please UseCodeTags.

Java class names, by convention, start with a capital letter, and do not contain underscroes: it's a good idea to follow those conventions to avoid confusion.

You're giving the name of a form as the collection name; that is almost certainly incorrect. You should provide an actual collection.



Thanks for replying
I will certainly change the names...
I am new to Struts..and i m really confused ...i m trying to iterate with logic:iterate tag..but my all effort is in vain...its give error that cannot iterate for this collection....please guide me what to do.please point out in my code what changes to be made..
thanks..
regards..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: want help with html:optionscollection tag...