Hi,
I have investigated the indexed properties as follows.
structure of my jsp page:
===================
<html:form action="/DisplayNestedPropertiesAction.do">
<logic:iterate name="nestedPropertiesForm" property="skills" id="skillBean">
<TABLE border="1" borderColor="cyan" cellpadding="0" cellpadding="0">
<TBODY>
<TR bgcolor="<bean:write name="skillBean" property="backgroundColor"/>">
<TD><html:checkbox name="skillBean" property="checkbox" styleClass="clickclass"
indexed="true" onclick="Javascript:ViewTheSkill()"/></TD>
<TD><bean:write name="skillBean" property="qualification"/></TD>
<TD><bean:write name="skillBean" property="profession"/></TD>
</TR>
</TBODY>
</TABLE>
</logic:iterate>
</html:form>
ActionForm:
=========
public class NestedPropertiesForm extends FWKActionForm{
/**
*
*/
public NestedPropertiesForm() {
super();
}
/**
* Permet de r�cup�rer la collection "skills" des objets skillBean
*/
protected List skills = new ArrayList();
/**
* Permet de r�cup�rer la collection "skills" des objets skillBean
*/
public List getSkills() {
return skills;
}
public void setSkills(List skills) {
this.skills = skills;
}
/**
* Permet de r�cup�rer dans l'action, l'objet indic� "index" de la liste.
* @param index
* @return
*/
public SkillBean getSkills(int index) {
// automatically grow List size
while (index >= skills.size()) {
skills.add(new SkillBean());
}
return (SkillBean)skills.get(index);
}
public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
//I would like to initialize the checkbox properties here to false...
}
public void init(){
skills = new ArrayList();
}
}
embeded Bean:
******************
public class SkillBean {
private boolean checkbox;
private String qualification;
private String profession;
/**
*
*/
public SkillBean() {
super();
// TODO Raccord de constructeur auto-g�n�r�
}
/**
*
*/
public SkillBean(boolean checkBox, String qualif, String profession) {
super();
// TODO Raccord de constructeur auto-g�n�r�
this.checkbox = checkBox;
this.qualification = qualif;
this.profession = profession;
}
/**
* @return
*/
public boolean getCheckbox() {
return checkbox;
}
/**
* @return
*/
public String getProfession() {
return profession;
}
/**
* @return
*/
public String getQualification() {
return qualification;
}
/**
* @param string
*/
public void setCheckBox(boolean checkBox) {
this.checkbox = checkBox;
}
/**
* @param string
*/
public void setQualification(String string) {
qualification = string;
}
/**
* @param string
*/
public void setProfession(String string) {
profession = string;
}
}
Action:
=====
public class NestedPropertiesAction extends Action{
public ActionForward execute(ActionMapping arg0,
ActionForm arg1,
HttpServletRequest arg2,
HttpServletResponse arg3) throws Exception {
NestedPropertiesForm nestedPropertiesForm = (NestedPropertiesForm)arg1;
List skillBeanList = createSkillList();
nestedPropertiesForm.setSkills(skillBeanList);
return arg0.findForward("nestedPropertiesPage");
}
}
public static List createSkillList(){
List skillBeanList = new ArrayList();
SkillBean skillBean1 = new SkillBean(false, "Engineer", "Developer");
SkillBean skillBean2 = new SkillBean(true, "practician", "surg");
SkillBean skillBean3 = new SkillBean(false, "Architect", "Maintenance
Appareil");
skillBeanList.add(skillBean1);
skillBeanList.add(skillBean2);
skillBeanList.add(skillBean3);
return skillBeanList;
}
My questions:
==========
Please:
=====
1.)Am I missing something in this implementation?
2.) Knowing that the right way of correctly using a checkbox is to initialize
the checkbox property in the reset method; how can I do this in my actionForm
with the indexProperties?
3.) How can I get only the checked Bean in my action.
When I select a checkbox, I would like to trigger an action (/ViewTheSkill.do).
How can I get (ONLY) the corresponding bean in my action?
ViewTheSkill.execute(). I would like to use this bean for further processing.
public class ViewTheSkillAction extends Action{
public ActionForward execute(ActionMapping arg0,
ActionForm arg1,
HttpServletRequest arg2,
HttpServletResponse arg3) throws Exception {
NestedPropertiesForm nestedPropertiesForm = (NestedPropertiesForm)arg1;
//HOW CAN I get the checked SkillBean here?
}
}
Thanks very much.
---------------------------------
Cr�ez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Cr�ez votre Yahoo! Mail
Le nouveau Yahoo! Messenger est arriv� ! D�couvrez toutes les nouveaut�s pour
dialoguer instantan�ment avec vos amis.T�l�chargez GRATUITEMENT ici !