aspose file tools*
The moose likes Struts and the fly likes Dynamic radio buttons matrix using Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic radio buttons matrix using Struts" Watch "Dynamic radio buttons matrix using Struts" New topic
Author

Dynamic radio buttons matrix using Struts

Adolfo Gonzalez
Greenhorn

Joined: Feb 02, 2005
Posts: 11
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.


IBM 285, SCJP
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

Try using Indexed properties. Post again if you have trouble using them.


Junilu - [How to Ask Questions] [How to Answer Questions]
Adolfo Gonzalez
Greenhorn

Joined: Feb 02, 2005
Posts: 11
Thanks, it's working now
Adolfo Gonzalez
Greenhorn

Joined: Feb 02, 2005
Posts: 11
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

Joined: Feb 02, 2005
Posts: 11
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic radio buttons matrix using Struts