通过代码编写 JSF、commandButton 的导航-操作-结果
我尝试修复这样的难以管理的代码:
<a4j:commandButton action="dia_ok" actionListener="#{...}" ajaxSingle="true" .../>
我通过将按钮绑定到 ManagedBean 并将所有属性交换为 Java 代码来修复它,所以只有:
<a4j:commandButton binding="#{...}"/>
我成功编码了 setAjaxSingle(true) 和 actionListener 属性,但我失败了在代码上操作属性。
我的问题是:如何指定方法 button.setActionExpression() 只允许 MethodExpression 而不是 String 的参数的操作结果?
i try to fix unmanagable code like this:
<a4j:commandButton action="dia_ok" actionListener="#{...}" ajaxSingle="true" .../>
i fix it by bind the button to an ManagedBean and swap all the attributes to Java-Code, so ill only have:
<a4j:commandButton binding="#{...}"/>
I successfully coded setAjaxSingle(true) and the actionListener-attribute, but i fail on code the action-Attribute.
My question is: how can i specify the action-outcome whereat the method button.setActionExpression() does only allows argument of MethodExpression instead of String?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需创建一个值为
"dia_ok"
且返回类型为String
的MethodExpression
。该表达式不一定引用"#{bean.action}"
或其他内容。例如
。
,当您以这种方式将视图混合到模型中时,我只是看不到它如何使代码更易于管理 也许您需要编写一些通用约定,如何对属性进行排序/组织,以便更好地管理?例如首先是
id
,然后是value
,等等,然后与此约定保持一致。You can just create a
MethodExpression
with a value of"dia_ok"
and a return type ofString
. The expression does not necessarily refer to"#{bean.action}"
or something.E.g.
with
I only fail to see how it makes the code more manageable as you're mingling the view into the model this way. Perhaps you need to writeup some general convention how attributes should be ordered/organized so that it's better manageable? E.g.
id
first, thenvalue
, etc and then be consistent with this convention.