2013-07-16 10 views

回答

1

我想知道在哪个班这种渲染逻辑存在,该模型值渲染时提交值为null

你没有任何地方告诉正在使用的JSF实现。在这个答案中,我会假设它是Mojarra。在这种情况下,它在HtmlBasicRenderer#getCurrentValue()中完成。以下是来自Mojarra 1.2_15的相关摘录。

275 protected String getCurrentValue(FacesContext context, 
276          UIComponent component) { 
277 
278  if (component instanceof UIInput) { 
279   Object submittedValue = ((UIInput) component).getSubmittedValue(); 
280   if (submittedValue != null) { 
281    // may not be a String... 
282    return submittedValue.toString(); 
283   } 
284  } 
285 
286  String currentValue = null; 
287  Object currentObj = getValue(component); 
288  if (currentObj != null) { 
289   currentValue = getFormattedValue(context, component, currentObj); 
290  } 
291  return currentValue; 
292 
293 } 

代码可以说明问题。如果该组件是UIInput的实例,则获取其提交的值。如果它不是null,则返回它。否则,按照常规方式继续返回模型值。

MyFaces使用类似的方法。

+0

感谢BalusC,您的支持是非常有帮助的。 – RaoPotla

+0

不客气。 – BalusC