【问题标题】:Generic URL using template on action jsf在动作 jsf 上使用模板的通用 URL
【发布时间】:2015-01-26 17:35:30
【问题描述】:

我用 commandLink 创建了一个模板:

<div class="pull-right" style="padding: 5px">
    <h:commandLink action="#{urlVoltar}" styleClass="btn btn-sm btn-danger"><span class="fa fa-reply"></span></h:commandLink>
</div>

并在主页中使用它:

<ui:include src="/sistema/commonBotoesExportar.xhtml">
    <ui:param name="urlVoltar" value="\indexNovo.xhtml" />
</ui:include>

所以当我点击按钮时,我得到了这个异常:

javax.faces.el.EvaluationException: javax.el.ELException: //C:/project/WebContent/sistema/commonBotoesExportar.xhtml @13,154 action="#{urlVoltar}": Identity 'urlVoltar' does not reference a MethodExpression instance, returned type: java.lang.String
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
...

我需要做些什么来解决这个问题。谢谢

【问题讨论】:

    标签: jsf action facelets


    【解决方案1】:

    首先使用&lt;h:commandLink&gt; 进行页面到页面导航没有任何意义。它只会破坏网页的 SEO 和 UX。

    只需使用&lt;h:link&gt;

    <h:link outcome="#{urlVoltar}" ...>
    

    另见:


    如果您真的想在这个结构中使用&lt;h:commandXxx&gt; 组件,那么请转到这个重复的问题:Dynamic ui include and commandButton

    【讨论】:

    • 不客气。由于您是新来的,请不要忘记在回答(最)有助于理解和解决问题时将其标记为已接受。另见How does accepting an answer work?
    • 已标记。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 2010-10-28
    • 2012-08-23
    • 1970-01-01
    相关资源
    最近更新 更多