Chr*_*ris 5 lifecycle jsf components
如果我正确地将 BalusC 2006 年伟大的帖子http://balusc.blogspot.ch/2006/09/debug-jsf-lifecycle.html 中包含的信息与 Optimus Prime 更早的帖子http://cagataycivici.wordpress.com/2005 /12/28/jsf_component_s_value_local/我得到以下信息:
我的理解:
问题:
几乎是正确的。仅当转换和验证成功时才会设置组件的本地值。之后,将提交的值设置为null。您可以在方法中以相当自记录的方式找到验证阶段的整个过程UIInput#validate()(行号符合 JSF 2.1 API):
934 public void validate(FacesContext context) {
935
936 if (context == null) {
937 throw new NullPointerException();
938 }
939
940 // Submitted value == null means "the component was not submitted
941 // at all".
942 Object submittedValue = getSubmittedValue();
943 if (submittedValue == null) {
944 return;
945 }
946
947 // If non-null, an instanceof String, and we're configured to treat
948 // zero-length Strings as null:
949 // call setSubmittedValue(null)
950 if ((considerEmptyStringNull(context)
951 && submittedValue instanceof String
952 && ((String) submittedValue).length() == 0)) {
953 setSubmittedValue(null);
954 submittedValue = null;
955 }
956
957 Object newValue = null;
958
959 try {
960 newValue = getConvertedValue(context, submittedValue);
961 }
962 catch (ConverterException ce) {
963 addConversionErrorMessage(context, ce);
964 setValid(false);
965 }
966
967 validateValue(context, newValue);
968
969 // If our value is valid, store the new value, erase the
970 // "submitted" value, and emit a ValueChangeEvent if appropriate
971 if (isValid()) {
972 Object previous = getValue();
973 setValue(newValue);
974 setSubmittedValue(null);
975 if (compareValues(previous, newValue)) {
976 queueEvent(new ValueChangeEvent(this, previous, newValue));
977 }
978 }
979
980 }
Run Code Online (Sandbox Code Playgroud)
至于组件immediate上的属性UIInput,是的,这只是将验证转移到应用请求值阶段。UIInput#processDecodes()另请参阅和的源代码UIInput#processValidators(),对 进行检查UIInput#isImmediate()。
| 归档时间: |
|
| 查看次数: |
5103 次 |
| 最近记录: |