javax.faces.component.UIData.getRows 无法将 25 和 1000 解析为有效整数值
javax.faces.component.UIData.getRows fails to parse 25 and 1000 as valid integer values
我正在努力将 int
值传递给属性 rows
。
<p:dataTable rows="#{isLazy ? 25 : 1000}">
<f:attribute name="selectionMode" value="#{widget.selectionMode}"/>
<f:attribute name="selection" value="#{widget.selectionModel.selection}"/>
</p:dataTable>
javax.faces.component.UIData
中检索值的方法定义为
public int getRows() {
return (Integer) getStateHelper().eval(PropertyKeys.rows, 0);
}
getStateHelper().eval(PropertyKeys.rows, 0)
导致 Long
,此后无法转换为 Integer
。
- 有没有办法告诉解析器将表达式
isLazy ? 25 : 1000
的结果视为 int
或 Integer
?
- 是我的问题,还是演员写的太烂了?
我是 JSF 新手,如有任何帮助,我们将不胜感激。
更新 1:令人惊讶的是,如果我从 p:dataTable
. 中排除所有 <f:attribute />
,它会起作用(返回 Integer
)我完全懵了。
更新 2:我找到了一个糟糕的解决方法。我可以在 facelet-taglib
中定义一个函数,引用 Integer.valueOf(int)
<function>
<function-name>toInt</function-name>
<function-class>java.lang.Integer</function-class>
<function-signature>Integer valueOf(int)</function-signature>
</function>
并用它来总结我的价值。
<f:attribute name="rows" value="#{bg:toInt(1000)}"/>
我所谓的 "an awful workaround" 结果是我找到的唯一可行的解决方案。
我在 facelet-taglib
中定义了一个引用 Integer.valueOf(int)
的函数
<function>
<function-name>toInt</function-name>
<function-class>java.lang.Integer</function-class>
<function-signature>Integer valueOf(int)</function-signature>
</function>
并且可以用它来包装一个整数文字。
<f:attribute name="rows" value="#{bg:toInt(1000)}"/>
我的 facelet-taglib
这个定义乱七八糟,我有点讨厌它,但它确实有效。
有用的链接:
JSF composite:attribute with f:attribute conversion error
我正在努力将 int
值传递给属性 rows
。
<p:dataTable rows="#{isLazy ? 25 : 1000}">
<f:attribute name="selectionMode" value="#{widget.selectionMode}"/>
<f:attribute name="selection" value="#{widget.selectionModel.selection}"/>
</p:dataTable>
javax.faces.component.UIData
中检索值的方法定义为
public int getRows() {
return (Integer) getStateHelper().eval(PropertyKeys.rows, 0);
}
getStateHelper().eval(PropertyKeys.rows, 0)
导致 Long
,此后无法转换为 Integer
。
- 有没有办法告诉解析器将表达式
isLazy ? 25 : 1000
的结果视为int
或Integer
? - 是我的问题,还是演员写的太烂了?
我是 JSF 新手,如有任何帮助,我们将不胜感激。
更新 1:令人惊讶的是,如果我从 p:dataTable
. 中排除所有 <f:attribute />
,它会起作用(返回 Integer
)我完全懵了。
更新 2:我找到了一个糟糕的解决方法。我可以在 facelet-taglib
中定义一个函数,引用 Integer.valueOf(int)
<function>
<function-name>toInt</function-name>
<function-class>java.lang.Integer</function-class>
<function-signature>Integer valueOf(int)</function-signature>
</function>
并用它来总结我的价值。
<f:attribute name="rows" value="#{bg:toInt(1000)}"/>
我所谓的 "an awful workaround" 结果是我找到的唯一可行的解决方案。
我在 facelet-taglib
中定义了一个引用 Integer.valueOf(int)
<function>
<function-name>toInt</function-name>
<function-class>java.lang.Integer</function-class>
<function-signature>Integer valueOf(int)</function-signature>
</function>
并且可以用它来包装一个整数文字。
<f:attribute name="rows" value="#{bg:toInt(1000)}"/>
我的 facelet-taglib
这个定义乱七八糟,我有点讨厌它,但它确实有效。
有用的链接:
JSF composite:attribute with f:attribute conversion error