<html:select> with Yes/No options inside <logic:iterate> passing null to form in struts

332 views Asked by At

adminpage.jsp

I am iterating the users list from map and showing it in UI. Trying to send Yes/No values selected by user for agRestricted and processing it in the approve action.

 <logic:iterate name="usersDetails" id="user" indexId="index">    
    <td><bean:write name="user" property="agName" /></td>
    <td>
    <html:select property="agRestricted" name="user">
      <html:option value="Yes">Yes </html:option>
      <html:option value="No">No</html:option>
    </html:select>
    </td>
    <td>
    <html:button property="Approve" value="" title="Approve" onclick="adminApprove()"></html:button>
    </td>
    </logic:iterate> 

ApproveAction.java

In the approve action I am trying to read agRestricted value sent in form on submission. but Iam getting null here. Am I doing anything wrong.

    public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                HttpServletResponse response) throws Exception {
    RegistrationForm registrationForm = (RegistrationForm) form;
    if (loggingService.isInfoEnabled()) {
                loggingService.logInfo(this, "is AG Restricted", agRestricted);
            } // if{}//printing null

}

RegistrationForm.java

POJO Class for setting the form variables.

 public class RegistrationForm extends org.apache.struts.action.ActionForm {
    private String agRestricted;
        private String agName;
    public String getAgRestricted() {
            return agRestricted;
        }
        public void setAgRestricted(String agRestricted) {
            if (loggingService.isInfoEnabled()) {
                loggingService.logInfo(this, "is AG Restricted", agRestricted);
            } // if{}//printing null
            this.agRestricted = agRestricted;
        }
        public String getAgName() {
            return agName;
        }
        public void setAName(String agName) {
            this.agName = agName;
        }
}

adminpage.js

function adminApprove() {

var newUrl2 = './adminpage.do';
document.forms[0].action = newUrl2;
        document.forms[0].submit(); 

    }

struts-config.xml

<action input="/adminApprove" name="RegistrationForm"
            path="/adminpage" scope="request"
            type="com.cts.assetserv.core.web.action.ApproveAction" parameter="method">
            <forward name="Success" path="/adminpage.do" />
            <forward name="Error" path="/adminpage.do" />
        </action>
0

There are 0 answers