Domanda

I don't know if I'm doing something wrong or if it might be a bug or something.

My setup contains IntelliJ IDEA 12, JBoss AS 7.2.0.Final, Richfaces 4.3.4 within a war-File within an ear-Project (no Maven).

I have this index-page:

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">
    <rich:notifyMessage stayTime="3500" showShadow="true" showCloseButton="true" />
    <f:view>
        <h:head>    <title>     title   </title>    </h:head>
        <h:body>
            <!-- some more divs for page-design, but commented out at the moment -->
            <div id="page">
                <div id="index_workspace" style="width:1000px;margin:auto;">
                    <h:panelGrid columns="2" id="index_workspace_table">
                        <rich:panel id="index_workspace_navi_left" style="width:180px;min-height:600px;max-height:600px;">
                            <ui:include src="general/navi_left.xhtml"/>
                        </rich:panel>
                        <rich:panel id="index_workspace_content" style="width:550px; min-height:600px; max-height:600px;" rendered="#{not empty naviBean.content}">
                            <a4j:outputPanel id="index_workspace_content_ajax" ajaxRendered="true">
                                    <ui:include src="#{naviBean.content}" id="current_site" />
                            </a4j:outputPanel>
                        </rich:panel>
                    </h:panelGrid>
                </div>
            <!-- some more divs for page-design, but commented out at the moment -->
            </div>
        </h:body>
    </f:view>
</ui:composition>

Within the section I load the pages with forms and all the other cool stuff RF brings. But I have a rendering problem with this part of a loaded page:

<rich:select id="someID_1" rendered="true" immediate="true" required="true" enableManualInput="true" defaultLabel="someLabel">
    <a4j:ajax render="true">
        <f:selectItems id="selectlist" value="#{BackingBean.SelectableItem-ListGetter}"/>
    </a4j:ajax>
</rich:select>

And here my problem is located:

This drop-down list only gets rendered on a page reload, e.g. F5 or CTRL-R action. Also I could observe that if I set this element on some Kind of a "start page" (initially loaded on the index.xhtml) it gets rendered very well. In this case every other page containing this kind of element renders it correctly also.

I tried

  • updating JSF from 2.1 to 2.2.1 - that only brought up more problems - so I rolled it back.

  • The "standard" h:selectOneMenu behaves the same.

  • additional options within rich:select (e.g.: rendered, immediate, required, ...)

  • different ajax commands within the navigation (server, client, ajax, on different levels)

  • googling around since days - found no useable hint

I would appreciate every hint that guides me into the right direction as I feel confident, that I make some mistake I can't figure out...

Additionally my navigation looks like this (in another div on the index.xhtml):

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">
    <h:form id="navi_left">
        <rich:panel>
            <rich:panelMenu itemMode="ajax" groupMode="ajax" itemChangeListener="#{naviBean.updateContent}" >
            <rich:panelMenuGroup itemLeftIcon="disc" label="Erfassung" name="#{naviBean.content}">
                <rich:panelMenuItem label="someLabel_navi" name="path/to/page-not-getting-rendered-well.xhtml"/>
            </rich:panelMenuGroup>
         </rich:panel>
    </h:form>
</ui:component>

Hope this helps helping me.

È stato utile?

Soluzione 2

I think I found the problem. As my navigation and my desired site with the not correctly rendered component lie nested in <div>s on the third participating site - my index.xhtml - it seems to be impossible to let a jsf-component be rendered without having all (i.e. the navigation and the desired) sites processed on the server. So the following code-snippets work for my situation:

index.xhtml snippet:

<rich:panel id="index_workspace_content" style="width:550px; min-height:600px; max-height:600px;" rendered="#{not empty naviBean.content}">
    <ui:include src="#{naviBean.content}" id="current_site" />
</rich:panel>

navi_left.xhtml snippet:

<h:form id="navi_left">
    <rich:panel>
        <rich:panelMenu itemMode="server" groupMode="client" itemChangeListener="#{naviBean.updateContent}">
            <rich:panelMenuGroup label="someLabel" name="#{naviBean.content}">
                <rich:panelMenuItem label="anotherLabel" name="path/to/page-being-rendered-correctly.xhtml"/>
            </rich:panelMenuGroup>
...
</h:form>

component snippet in the desired.xhtml:

<rich:select id="someId" rendered="true" immediate="true" required="true" enableManualInput="true">
    <f:selectItems var="#{backingBean.selectableItemList}" id="selectlist" value="#{backingBean.predefinedItem}"/>
</rich:select>

So what I have changed is the itemMode to "server", both of the others (ajax and client) will not work! Setting the groupMode to "client" does not affect the renderprocess of desired.xhtml as it only describes the way the rich:panelMenu behaves.

What makes me feel a bit confused is, that the URL now gets extended with a "/index.xhtml". Before the change it was always just the url:port/context (e.g. localhost:8080/app ).

So it works now, but maybe it's not really what I wanted. I'll observe and report future facts concerning this itemMode-option here.

Altri suggerimenti

 <a4j:ajax render="true">
    <f:selectItems id="selectlist" value="#{BackingBean.SelectableItem-ListGetter}"/>
</a4j:ajax>

The above construct is not legal(as you've already seen yourself). The render attribute in there is not used for what you'd expect: to conditionally render the component; Rather, it's supposed to contain a list of on-page components to update via ajax.

To achieve the output I presume you're trying to get, you should use the following instead:

    <a4j:region>
       <rich:select id="someID_1" rendered="true" immediate="true" required="true" enableManualInput="true" defaultLabel="someLabel">
          <f:selectItems id="selectlist" value="#{BackingBean.SelectableItem-ListGetter}"/>
       </rich:select>
    <a4j:region>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top