相关疑难解决方法(0)

在EL中调用带参数/变量/参数的直接方法或方法

我如何在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.E​​LException:错误解析:#{bean.list.size()}
com.sun.el.parser.ParseException:遇到"("

methods jsf arguments el parameter-passing

25
推荐指数
1
解决办法
3万
查看次数

非请求范围Bean中的@ManagedProperty(value ="#{param.id}")

我需要将参数(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)

java jsf managed javabeans jsf-2

17
推荐指数
2
解决办法
3万
查看次数

如何在JSF中定义表单操作?

为了替换默认的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 …

forms jsf action

6
推荐指数
2
解决办法
5万
查看次数

标签 统计

jsf ×3

action ×1

arguments ×1

el ×1

forms ×1

java ×1

javabeans ×1

jsf-2 ×1

managed ×1

methods ×1

parameter-passing ×1