我如何在JSF 2.0中使用EL中的参数/变量/参数调用直接方法或方法?
例如,在EL中获取列表大小:
<h:outputText value="#{bean.list.size()}" />
Run Code Online (Sandbox Code Playgroud)
或者使用参数调用action方法:
<h:commandButton value="edit" action="#{bean.edit(item)}" />
Run Code Online (Sandbox Code Playgroud)
这在我的环境中似乎不起作用.它似乎不喜欢括号.
javax.el.ELException:错误解析:#{bean.list.size()}
com.sun.el.parser.ParseException:遇到"("
我需要将参数(POST)传递给@managedBean,我使用了这样的托管属性:
@ManagedProperty(value = "#{param.id}")
private int id;
Run Code Online (Sandbox Code Playgroud)
Bean的范围是ViewScope
我最终得到了这个错误:
无法创建托管bean收据.发现了以下问题: - 表达式#{param.id},request引用的对象的范围比引用的托管bean范围短
我能做什么?
arjan看看:
我的页面:Facelet Title
<form method="post" action="faces/index.xhtml">
<input name="id" value="4" />
<input type="submit" value="submit" />
</form>
<h:form>
<h:commandLink value="click" action="index">
<f:param id="id" name="id" value="20"/>
</h:commandLink>
</h:form>
Run Code Online (Sandbox Code Playgroud)
为了替换默认的Spring安全登录表单,我提出了这个解决方案:
<form name="f" action="../j_spring_security_check" method="POST" >
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Login" />
</form>
Run Code Online (Sandbox Code Playgroud)
但是<form>我想使用普通标签而不是普通标签,<h:form>因为Primefaces组件只能在其中工作<h:form>.使用<h:form>表单操作将由JSF自动设置到当前页面,而不是上面示例中我设置的值."../j_spring_security_check"现在我必须在哪里编写动作?我尝试将其放入<h:commandButton>如下,但这不起作用:
<h:form name="f">
<h:panelGrid columns="2">
<h:outputText value="Username" />
<h:inputText id="j_username" />
<h:outputText value="Password" />
<h:inputText id="j_password" />
</h:panelGrid>
<h:commandButton value="Click here" action="../j_spring_security_check" />
</form>
Run Code Online (Sandbox Code Playgroud)
它会导致错误消息Unable to find matching navigation case with from-view-id '/login.xhtml' for action '../j_spring_security_check' with outcome '../j_spring_security_check'.
这是定义导航案例的唯一方法faces-config.xml …