0

我是 struts 新手,单击单选按钮时会收到“java.lang.NullPointerException”。我有两种不同类型的用户(中央和本地),它们映射到不同的单选按钮。我的表单上还有一个下拉框。我想让中央用户禁用它。

我只知道标签中的属性必须相同才能创建一个无线电组,但在我的情况下属性可能是什么?我之前尝试了很多方法,但仍然得到 NullPointerException。

任何建议将不胜感激!

   -----------in my jsp page:

  $(document).ready(function() {

// Check if radio buttons exists
    if ($('#centralAdmintype').length > 0) {
        $('#unitOption').attr('disabled', true);
        $('#centralAdmintype').bind('click', function() {
            var checkval = $('#centralAdmintype').is(":checked");
            if (checkval) {
                $('#unitOption').attr('disabled', true);
                $('#unitOption').data('unitId', "0");
            }
        });
        $('#localAdminType').bind('click', function() {
            var checkval = $('#localAdminType').is(":checked");
            if (checkval) {
                $('#unitOption').removeAttr('disabled');
            }
        });
    }
});

------------ 在正文标签中

<logic:equal name="unitSelectionForm" property="centralAndLocalRoles" value="true">

   <html:radio name="unitSelectionForm" id="centralAdmintype" property="centralRole"   value="0" />Central    
   <html:radio name="unitSelectionForm" id="localAdminType" property="localRole" value="1" />Local

------------在我的行动表格中,我有:

protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws TechnicalException {
    String forward = DispatchStrings.FORWARD_SUCCESS;
    UnitSelectionForm unitSelForm = (UnitSelectionForm) form;
    unitSelForm.setCentralAndLocalRoles(true);

    boolean hasRadioButton =false;
    boolean hasCentralRole = false;
    boolean hasLocalRole = false;
    hasRadioButton = unitSelForm.getCentralAndLocalRoles();

    if (hasRadioButton) {
        hasCentralRole = unitSelForm.getCentralRole();
        hasLocalRole = unitSelForm.getLocalRole();
    }           
    try{
        if(hasRadioButton && hasCentralRole){
            forward = DispatchStrings.FORWARD_SUCCESS;
        }

------------- 在我的 Bean 类中

  public class UnitSelectionForm extends SaltValidatorForm 

    {
      private Integer unitId;
      private OptionForm units[];
      private String loginname;
      private Integer administratorType;
      private Boolean centralRole;
      private Boolean localRole;
      private Boolean centralAndLocalRoles;         
4

0 回答 0