• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic radio buttons matrix using Struts

 
Adolfo Gonzalez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I�ve a problem, please if somebody could help me I�ll really appreciate it.

I have a dynamic matrix with radio buttons, only the number of rows could change. The matrix is as follows, it has 4 static columns of radio buttons and for each row I can select only one (radio button):

Skill 1OOOO
Skill 2OOOO
Skill 3OOOO
Skill nOOOO

How could I store the selected radio buttons in the ActionForm? Whichever information you have that it could help me, I�d really appreciate it.
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using Indexed properties. Post again if you have trouble using them.
 
Adolfo Gonzalez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, it's working now
 
Adolfo Gonzalez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I get this error when sending the parameters to action that saves the
information in tha database, the creation of the form is successfull.

Any ideas, about how to name the getters/setters for the indexed
properties.

This is part of the ActionForm code:



public class CaSkillAssessmentForm extends ActionForm
{

/******************************************************************************
Attributes
******************************************************************************/

/**
* Skills with Scope
*/
private Vector skillsWithScore = new Vector();


/******************************************************************************
Accessors
******************************************************************************/

/**
* Get skillsWithScope
* @return Collection
*/
public CbSkill getSkillsWithScoreIndexed(int index)
{
return (CbSkill) skillsWithScore.get(index);
}
/**
* Get skillsWithScope
* @return Collection
*/
public Vector getSkillsWithScore()
{
return skillsWithScore;
}

/**
* Set skillsWithScope
* @param <code>int</code>
* @param <code>Collection</code>
*/
public void setSkillsWithScoreIndexed(int index, CbSkill paramSkillsWithScore)
{
skillsWithScore.add(index, paramSkillsWithScore);
}

/**
* Set skillsWithScope
*
* @param paramSkills
*/
public void setSkillsWithScore(Vector paramSkills)
{
skillsWithScore = paramSkills;
}

/******************************************************************************
Public Operations
******************************************************************************/
public void reset(ActionMapping mapping, HttpServletRequest request)
{

skillsWithScore = null;

}

public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request)
{

ActionErrors errors = new ActionErrors();

return errors;

}
}


This is the jsp:

<logic:iterate id="skills" name="caSkillAssessmentForm" property="skillsWithScore" indexId="index">
<tr valign="middle" class="datatablecolor2">
<td class="tdleft">
<bean:write name="skills" property="name"/>
</td>
<td class="tdleft">
<html:radio property="<%= \"skillsWithScoreIndexed[\"+ index+\"].scoreId\"%>" value="1"/>
</td>
<td class="tdleft">
<html:radio property="<%= \"skillsWithScoreIndexed[\"+ index+\"].scoreId\"%>" value="2"/>
</td>
<td class="tdleft">
<html:radio property="<%= \"skillsWithScoreIndexed[\"+ index+\"].scoreId\"%>" value="3"/>
</td>
<td class="tdleft">
<html:radio property="<%= \"skillsWithScoreIndexed[\"+ index+\"].scoreId\"%>" value="4"/>
</td>
</tr>
</logic:iterate>
 
Adolfo Gonzalez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry this is the error


SRVE0026E: [Servlet Error]-[BeanUtils.populate]: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor129.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:493)
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:770)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:881)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252)
at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic