Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

want help with html:optionscollection tag...

 
sruti roy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic