通用 URL 在动作 jsf 上使用模板
Generic URL using template on action jsf
我用 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)
...
我需要做什么来解决这个问题。谢谢
首先,使用 <h:commandLink>
进行页面导航毫无意义。它只会破坏网页的 SEO 和 UX。
只需使用 <h:link>
.
<h:link outcome="#{urlVoltar}" ...>
另请参阅:
- When should I use h:outputLink instead of h:commandLink?
- How to navigate in JSF? How to make URL reflect current page (and not previous one)
如果您真的喜欢在此构造中使用<h:commandXxx>
组件,请转到这个重复的问题:Dynamic ui include and commandButton.
我用 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)
...
我需要做什么来解决这个问题。谢谢
首先,使用 <h:commandLink>
进行页面导航毫无意义。它只会破坏网页的 SEO 和 UX。
只需使用 <h:link>
.
<h:link outcome="#{urlVoltar}" ...>
另请参阅:
- When should I use h:outputLink instead of h:commandLink?
- How to navigate in JSF? How to make URL reflect current page (and not previous one)
如果您真的喜欢在此构造中使用<h:commandXxx>
组件,请转到这个重复的问题:Dynamic ui include and commandButton.