JSF呈现不工作 [英] JSF rendered is not working

查看:84
本文介绍了JSF呈现不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的事情在我的网页,选择/下拉菜单。这个下拉菜单应该产生另一个下拉基础上选定的项目菜单。我这样做,该方法是调用< F:Ajax事件=改变..监听器= ..>

I have something like this on my webpage, a select/drop down menu. This drop down menu should generate another drop down menu based on selected item. The way I am doing it, is by calling <f:ajax event="change"..listener=..>

但它没有发生如我所料。虽然选择在下拉菜单项触发听者在AJAX标签,下面的下降渲染属性下表似乎没有受到改变。而对于渲染的值更改成功从虚假到真实的。 Which..made我不知道什么是错误的,我JSF页面。

But it is not happening as I expected. While selecting item in the dropdown menu trigger the listener in the ajax tag, the rendered property of the following drop down tables seems not affected by the changes. And the value for rendered changed successfully from false to true. Which..made me wonder what is wrong in my jsf page.

下面是XHTML                                                                           

Here is the xhtml '

                        <h:selectOneMenu value="#{teacher.viewCategory}">
                            <f:selectItem itemValue="0" itemLabel="Tahun" />
                            <f:selectItem itemValue="1" itemLabel="Mata Pelajaran" />
                            <f:ajax event="change" render="divYearSelection divCourseSelection"
                                    listener="#{teacher.enableViewCategory}"/>
                        </h:selectOneMenu>

                        <h:panelGroup id="divYearSelection" layout="block" rendered="#{teacher.showViewYearSelection}">
                            <h:outputText value="YEAR"/>
                        </h:panelGroup>

                        <h:panelGroup id="divCourseSelection" layout="block" rendered="#{teacher.showViewCourseSelection}">
                            <h:outputText value="COURSE"/>
                        </h:panelGroup>


                        <h:commandButton value="#{msg.tcr_form_submit_view}" action="#{teacher.viewTeacher}"/>
                    </h:panelGrid>
                </h:form>' 

这是bean的功能,支持AJAX

and this is the bean's function supporting the ajax

public void enableViewCategory(AjaxBehaviorEvent e) {       
        if (this.getViewCategory().equals("0")) {
            this.setShowViewYearSelection(true);
        } else {
            this.setShowViewCourseSelection(true);
        }
    } 

当我调试,功能工作正常。

When I debugged , the function works fine.

推荐答案

如果部分呈现不起作用一个很好的出发点是寻找到您的网页的HTML源代码,因为它是在浏览器中呈现。你的渲染=divYearSelection将只有两个工作(阿贾克斯触发组件和目标组件)具有相同的直接父容器。

If partial rendering doesn't work a good starting point is to look into html source of your page as it is rendered in browser. Your render="divYearSelection" will only work if both (the ajax triggering component and the target component) have the same direct parent container.

渲染HTML组件的IDS通常看起来像 ID =formId:的ComponentID:nestedComponentId1 ID =formId:的ComponentID:nestedComponentId2

Ids of rendered html components usually look like id="formId:componentId:nestedComponentId1" or id="formId:componentId:nestedComponentId2"

因此​​,一个渲染=nestedComponentId2从COMPONENT1称为只会工作,如果二者IDS具有相同的预告片。

So a render="nestedComponentId2" called from component1 will only work if both ids have the same "trailer".

您可以尝试使用完整的ID作为例子给出先从形式的ID或替代(如果整个形式是不是太大)使用渲染=@表这将更新整个窗体。

You could try to use the complete id as given in the example starting with the id of the form or alternatively (if the whole form is not too big) use render="@form" which updates the whole form.

这篇关于JSF呈现不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆