Program: 60632
Project: 60632
Buggy source:
/** 
 * Attribute Mapping Panel.
 * @param panelid panel id.
 * @param resourceTO external resource.
 * @param createFlag create flag.
 */
public ResourceMappingPanel(final String panelid,final ResourceTO resourceTO,final boolean createFlag){
  super(panelid);
  setOutputMarkupId(true);
  this.resourceTO=resourceTO;
  this.createFlag=createFlag;
  initResourceSchemaNames();
  final AjaxTextFieldPanel accountLink=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  add(accountLink);
  mappingContainer=new WebMarkupContainer("String_Node_Str");
  mappingContainer.setOutputMarkupId(true);
  add(mappingContainer);
  mappings=new ListView<SchemaMappingTO>("String_Node_Str",resourceTO.getMappings()){
    /** 
 * Serial version UID.
 */
    private static final long serialVersionUID=4949588177564901031L;
    @Override protected void populateItem(    final ListItem<SchemaMappingTO> item){
      final SchemaMappingTO mappingTO=item.getModelObject();
      final Entity entity=mappingTO.getIntMappingType() == null ? null : mappingTO.getIntMappingType().getEntity();
      attrTypes=getAttributeTypes(entity);
      item.add(new AjaxDecoratedCheckbox("String_Node_Str",new Model(Boolean.FALSE)){
        private static final long serialVersionUID=7170946748485726506L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          int index=-1;
          for (int i=0; i < resourceTO.getMappings().size() && index == -1; i++) {
            if (mappingTO.equals(resourceTO.getMappings().get(i))) {
              index=i;
            }
          }
          if (index != -1) {
            resourceTO.getMappings().remove(index);
            item.getParent().removeAll();
            target.add(mappingContainer);
          }
        }
        @Override protected IAjaxCallDecorator getAjaxCallDecorator(){
          return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()){
            private static final long serialVersionUID=-7927968187160354605L;
            @Override public CharSequence preDecorateScript(            final CharSequence script){
              return "String_Node_Str" + getString("String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str"+ "String_Node_Str";
            }
          }
;
        }
      }
);
      final AjaxDropDownChoicePanel intAttrNames=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
      intAttrNames.setChoices(schemaNames);
      intAttrNames.setRequired(true);
      intAttrNames.setStyleShet(fieldStyle);
      setAttrNames(mappingTO.getIntMappingType(),intAttrNames);
      item.add(intAttrNames);
      final AjaxDropDownChoicePanel typesPanel=new AjaxDropDownChoicePanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<IntMappingType>(mappingTO,"String_Node_Str"),false);
      typesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          setAttrNames((IntMappingType)typesPanel.getModelObject(),intAttrNames);
          target.add(intAttrNames);
        }
      }
);
      typesPanel.setRequired(true);
      typesPanel.setChoices(attrTypes);
      typesPanel.setStyleShet(fieldStyle);
      item.add(typesPanel);
      final AjaxDropDownChoicePanel mappingTypesPanel=new AjaxDropDownChoicePanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new Model(entity),false);
      mappingTypesPanel.setChoices(Arrays.asList(Entity.values()));
      mappingTypesPanel.setStyleShet(defFieldStyle);
      item.add(mappingTypesPanel);
      mappingTypesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          attrTypes=getAttributeTypes((Entity)mappingTypesPanel.getModelObject());
          typesPanel.setChoices(attrTypes);
          intAttrNames.setChoices(Collections.EMPTY_LIST);
          target.add(typesPanel.getField());
          target.add(intAttrNames.getField());
        }
      }
);
      final FieldPanel extAttrName;
      if (schemaNames.isEmpty()) {
        extAttrName=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<String>(mappingTO,"String_Node_Str"),true);
      }
 else {
        extAttrName=new AjaxDropDownChoicePanel<String>("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
        ((AjaxDropDownChoicePanel)extAttrName).setChoices(schemaNames);
      }
      boolean required=mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword();
      extAttrName.setRequired(required);
      extAttrName.setEnabled(required);
      extAttrName.setStyleShet(fieldStyle);
      item.add(extAttrName);
      final AjaxTextFieldPanel mandatory=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
      mandatory.setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
      mandatory.setStyleShet(shortFieldStyle);
      item.add(mandatory);
      final AjaxCheckBoxPanel accountId=new AjaxCheckBoxPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),false);
      accountId.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
          extAttrName.setModelObject(null);
          extAttrName.setRequired(!accountId.getModelObject());
          target.add(extAttrName);
        }
      }
);
      item.add(accountId);
      final AjaxCheckBoxPanel password=new AjaxCheckBoxPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
      password.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
          extAttrName.setModelObject(null);
          extAttrName.setRequired(!password.getModelObject());
          target.add(extAttrName);
        }
      }
);
      item.add(password);
    }
  }
;
  mappings.setReuseItems(true);
  mappingContainer.add(mappings);
  addMappingBtn=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
    private static final long serialVersionUID=-4804368561204623354L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form form){
      resourceTO.getMappings().add(new SchemaMappingTO());
      target.add(mappingContainer);
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
    }
  }
;
  addMappingBtn.setDefaultFormProcessing(false);
  addMappingBtn.setEnabled(!createFlag);
  mappingContainer.add(addMappingBtn);
}

Fixed version (ground truth):
/** 
 * Attribute Mapping Panel.
 * @param panelid panel id.
 * @param resourceTO external resource.
 * @param createFlag create flag.
 */
public ResourceMappingPanel(final String panelid,final ResourceTO resourceTO,final boolean createFlag){
  super(panelid);
  setOutputMarkupId(true);
  this.resourceTO=resourceTO;
  this.createFlag=createFlag;
  initResourceSchemaNames();
  final AjaxTextFieldPanel accountLink=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  add(accountLink);
  mappingContainer=new WebMarkupContainer("String_Node_Str");
  mappingContainer.setOutputMarkupId(true);
  add(mappingContainer);
  mappings=new ListView<SchemaMappingTO>("String_Node_Str",resourceTO.getMappings()){
    /** 
 * Serial version UID.
 */
    private static final long serialVersionUID=4949588177564901031L;
    @Override protected void populateItem(    final ListItem<SchemaMappingTO> item){
      final SchemaMappingTO mappingTO=item.getModelObject();
      final AttributableType entity=mappingTO.getIntMappingType() == null ? null : mappingTO.getIntMappingType().getAttributableType();
      attrTypes=getAttributeTypes(entity);
      item.add(new AjaxDecoratedCheckbox("String_Node_Str",new Model(Boolean.FALSE)){
        private static final long serialVersionUID=7170946748485726506L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          int index=-1;
          for (int i=0; i < resourceTO.getMappings().size() && index == -1; i++) {
            if (mappingTO.equals(resourceTO.getMappings().get(i))) {
              index=i;
            }
          }
          if (index != -1) {
            resourceTO.getMappings().remove(index);
            item.getParent().removeAll();
            target.add(mappingContainer);
          }
        }
        @Override protected IAjaxCallDecorator getAjaxCallDecorator(){
          return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()){
            private static final long serialVersionUID=-7927968187160354605L;
            @Override public CharSequence preDecorateScript(            final CharSequence script){
              return "String_Node_Str" + getString("String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str"+ "String_Node_Str";
            }
          }
;
        }
      }
);
      final AjaxDropDownChoicePanel intAttrNames=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
      intAttrNames.setChoices(schemaNames);
      intAttrNames.setRequired(true);
      intAttrNames.setStyleShet(fieldStyle);
      setAttrNames(mappingTO.getIntMappingType(),intAttrNames);
      item.add(intAttrNames);
      final AjaxDropDownChoicePanel typesPanel=new AjaxDropDownChoicePanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<IntMappingType>(mappingTO,"String_Node_Str"),false);
      typesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          setAttrNames((IntMappingType)typesPanel.getModelObject(),intAttrNames);
          target.add(intAttrNames);
        }
      }
);
      typesPanel.setRequired(true);
      typesPanel.setChoices(attrTypes);
      typesPanel.setStyleShet(fieldStyle);
      item.add(typesPanel);
      final AjaxDropDownChoicePanel mappingTypesPanel=new AjaxDropDownChoicePanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new Model(entity),false);
      mappingTypesPanel.setChoices(Arrays.asList(AttributableType.values()));
      mappingTypesPanel.setStyleShet(defFieldStyle);
      item.add(mappingTypesPanel);
      mappingTypesPanel.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          attrTypes=getAttributeTypes((AttributableType)mappingTypesPanel.getModelObject());
          typesPanel.setChoices(attrTypes);
          intAttrNames.setChoices(Collections.EMPTY_LIST);
          target.add(typesPanel.getField());
          target.add(intAttrNames.getField());
        }
      }
);
      final FieldPanel extAttrName;
      if (schemaNames.isEmpty()) {
        extAttrName=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel<String>(mappingTO,"String_Node_Str"),true);
      }
 else {
        extAttrName=new AjaxDropDownChoicePanel<String>("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
        ((AjaxDropDownChoicePanel)extAttrName).setChoices(schemaNames);
      }
      boolean required=mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword();
      extAttrName.setRequired(required);
      extAttrName.setEnabled(required);
      extAttrName.setStyleShet(fieldStyle);
      item.add(extAttrName);
      final AjaxTextFieldPanel mandatory=new AjaxTextFieldPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
      mandatory.setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
      mandatory.setStyleShet(shortFieldStyle);
      item.add(mandatory);
      final AjaxCheckBoxPanel accountId=new AjaxCheckBoxPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),false);
      accountId.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
          extAttrName.setModelObject(null);
          extAttrName.setRequired(!accountId.getModelObject());
          target.add(extAttrName);
        }
      }
);
      item.add(accountId);
      final AjaxCheckBoxPanel password=new AjaxCheckBoxPanel("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str").getObject(),new PropertyModel(mappingTO,"String_Node_Str"),true);
      password.getField().add(new AjaxFormComponentUpdatingBehavior(onchange){
        private static final long serialVersionUID=-1107858522700306810L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
          extAttrName.setModelObject(null);
          extAttrName.setRequired(!password.getModelObject());
          target.add(extAttrName);
        }
      }
);
      item.add(password);
    }
  }
;
  mappings.setReuseItems(true);
  mappingContainer.add(mappings);
  addMappingBtn=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
    private static final long serialVersionUID=-4804368561204623354L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form form){
      resourceTO.getMappings().add(new SchemaMappingTO());
      target.add(mappingContainer);
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
    }
  }
;
  addMappingBtn.setDefaultFormProcessing(false);
  addMappingBtn.setEnabled(!createFlag);
  mappingContainer.add(addMappingBtn);
}