를 저장하지SelectManyBox - 열거 형은 .. 난 아직도 selectManyCheckBox에 문제가
selectManyCheckBox : 여기에 설명 된대로
이 selectManyCheckBox에 대한<p:selectManyCheckbox converter="genericEnumConverter" value="#{aView.newObject.aValue}">
<f:selectItems value="#{enumBean.aValueValues}" var="s" itemValue="#{s}" itemLabel = "#{s.name}"/>
</p:selectManyCheckbox>
컨버터는 동일합니다 Use enum in h:selectManyCheckbox
@FacesConverter("genericEnumConverter")
public class GenericEnumConverter implements Converter {
private static final String ATTRIBUTE_ENUM_TYPE = "GenericEnumConverter.enumType";
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
System.out.println("getAsString 1: ");
if (value instanceof Enum) {
System.out.println("getAsString 2: ");
component.getAttributes().put(ATTRIBUTE_ENUM_TYPE, value.getClass());
System.out.println("getAsString 3: ");
return ((Enum<?>) value).name();
} else {
System.out.println("getAsString 4: ");
throw new ConverterException(new FacesMessage("Value is not an enum: " + value.getClass()));
}
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Object getAsObject(FacesContext context, UIComponent component, String value) {
System.out.println("getAsObject 1: ");
Class<Enum> enumType = (Class<Enum>) component.getAttributes().get(ATTRIBUTE_ENUM_TYPE);
System.out.println("getAsObject 2: ");
try {
System.out.println("getAsObject 3: ");
return Enum.valueOf(enumType, value);
} catch (IllegalArgumentException e) {
System.out.println("getAsObject 4: ");
throw new ConverterException(new FacesMessage("Value is not an enum of type: " + enumType));
}
}
열거 형 :
public enum aValue {
1Value,
2Value,
3Value,
4Value;
private final String name;
private aValue() {
System.out.println("aValue 1");
this.name = null;
System.out.println("aValue 2");
}
public String getName() {
System.out.println("getName 1 " + name());
return ResourceBundleUtil.getLabelFromRb("aValue." + name());
}
}
public aValue[] getAValueValues() {
return AValue.values();
}
톰캣 로그는 다음과 같습니다
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
aValue 1
aValue 2
getName 1Value
getName 2Value
getName 3Value
getName 4Value
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getName 1Value
getName 2Value
getName 3Value
getName 4Value
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
getAsString 1:
getAsString 2:
getAsString 3:
내가 저장 버튼을 누르면 아무 일도 발생하지 않습니다 아무것도는 데이터베이스에 저장되지 않습니다. getAsObject 메소드에 들어 가지 않는 것 같습니다. 나는 이유를 모른다. 구성 요소를 SelectOneMenu로 변경하면 아무런 문제가 없습니다. 그러나이 selectManyCheckBox 것은 작동하지 않습니다. 누구 아이디어가 있습니까?
'p : commandButton'을 사용하는 경우'ajax = "false"'속성을 추가하고 검사 이벤트가 발생하는지 여부를 확인하십시오. – pudaykiran
상황에 대한 나의 승인은 javax.faces.component.UIinput의 processDecodes (FacesContext context)와 getConvertedValue (context, submittedValue)에 중단 점을 넣고 자세한 대답을위한 요청 매개 변수 –