相关疑难解决方法(0)

如何使用JSF 2.0 Facelets在XHTML中包含另一个XHTML?

在XHTML页面中包含另一个XHTML页面的最正确方法是什么?我一直在尝试不同的方式,但都没有.

xhtml jsf facelets include jsf-2

216
推荐指数
2
解决办法
26万
查看次数

JSF/Primefaces - ui:p:ajax元素中的param

我正在Java EE 6中编写应用程序,并使用Primefaces 3.4.1作为用户界面.

我有类似的东西.

genericPage.xhtml

<ui:composition template="mainApplicationTemplate.xhtml" [...]>
    <p:tabView id="tabView" dynamic="false"cache="false">
        <p:tab id="tab1" title="Tab 1">
            <h:form id="form1">
                ...
            </h:form>
        </p:tab>
        <p:tab id="tab1" title="Tab 1">
            <h:form id="form2">
                ...
            </h:form>
        </p:tab>
    </p:tabView>
<ui:composition >
Run Code Online (Sandbox Code Playgroud)

child1.xmtml

<ui:composition template="genericPage.xhtml" ...>
    <ui:param name="actionBean" value="#{actionBeanA}"/>
</ui:compisition>
Run Code Online (Sandbox Code Playgroud)

child2.xmtml

<ui:composition template="genericPage.xhtml" ...>
    <ui:param name="actionBean" value="#{actionBeanB}"/>
</ui:compisition>
Run Code Online (Sandbox Code Playgroud)

其背后的想法是child1.xhtml和child2.xhtml共享相同的jsf代码,全部包含在genericPage.xhtml中,但它们有不同的后端bean(由"actionBean"参数化)

到目前为止,效果非常好.当我将ui参数放在<p:ajax/>元素中时,它会变得复杂.

从后端bean,我需要以编程方式更新活动选项卡,而保持另一个不变.为此,我需要将活动选项卡存储在操作bean中.当发生某些外部事件时,操作bean会更新活动选项卡.

请注意,由于其他一些因素:

  • 我无法dynamic="true"进入tabView
  • 我不能有一个全局形式tabView,因此不能使用'activeIndex'属性(我在应用程序的其他部分做)来管理活动选项卡.

我想做的事

要解决这个问题,我想使用元素的tabChange事件tabView:

<p:tabView id="tabView" dynamic="false"cache="false">
        <p:ajax event="tabChange" listener="#{actionBean.listen}"
        <p:tab id="tab1" title="Tab 1">
            <h:form id="form1"> …
Run Code Online (Sandbox Code Playgroud)

java ajax jsf java-ee primefaces

4
推荐指数
1
解决办法
6344
查看次数

将actionListener方法名称作为参数传递以包含视图

我正在尝试将动作参数传递给我的页面中的局部视图,但出于某种原因,它表示我的参数是null,即使它是在外部页面中使用的bean.

页:

<ui:include src="/templates/common/ajaxConfirmPopup.xhtml">
    <ui:param name="bean" value="#{paginaBean}" />
    <ui:param name="action" value="deleteAll" />
</ui:include>
Run Code Online (Sandbox Code Playgroud)

在部分中调用动作:

actionListener="#{bean[action]}"
Run Code Online (Sandbox Code Playgroud)

但我得到以下异常:

Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:98) [jbossweb-7.0.13.Final.jar:]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:244) [jbossweb-7.0.13.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
Run Code Online (Sandbox Code Playgroud)

难道我做错了什么?

注意:当方法有ActionEvent参数时,一切正常,当方法没有参数时,它不工作.

facelets jsf-2

4
推荐指数
1
解决办法
2879
查看次数

facelets:使用ui:param将bean名称传递给action属性

由于某些自定义组件在其属性中需要bean名称(不是bean实例),我需要在页面之间传递实际的bean名称.由于bean本身也被非自定义组件使用,我想避免使用额外的ui:param(如此处所描述的在<rich:modalPanel>中传递操作),因为它基本上指定了相同的bean.

是否可以使用提供的bean名称指定组件的操作ui:param

基本上我试图实现以下目标:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/template.xhtml">

   <ui:param name="beanName" value="sessionBean"/>
   ...

</ui:composition>
Run Code Online (Sandbox Code Playgroud)

和template.xhtml是

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
template="/someothertemplate.xhtml">

  </ui:define name="somename">
    <h:form>
        <a4j:commandButton value="test" action="#{beanName.delete}"/>
    </h:form>
  </ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

虽然删除方法已正确定义(验证action="#{sessionBean.delete}"),但上面的代码给了我

javax.faces.FacesException:#{beanName.delete}:javax.el.MethodNotFoundException:/template.xhtml @ 201,89 action ="#{beanName.delete}":找不到方法:sessionBean.delete()

jsf facelets ajax4jsf

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

标签 统计

facelets ×3

jsf ×3

jsf-2 ×2

ajax ×1

ajax4jsf ×1

include ×1

java ×1

java-ee ×1

primefaces ×1

xhtml ×1