с параметрами Да / Нет внутрипередавая ноль, чтобы сформировать в стойках - PullRequest
0 голосов
/ 10 октября 2018

adminpage.jsp

Я перебираю список пользователей с карты и показываю его в пользовательском интерфейсе.Попытка отправить значения Да / Нет, выбранные пользователем для agRestricted, и обработать их в действии утверждения.

 <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

В действии утверждения япытается прочитать значение agRestricted, отправленное в форме при отправке.но я теряю здесьЯ делаю что-то не так.

    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 Класс для установки переменных формы.

 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>
...