views:

1369

answers:

2

Hello I have a JSF/RichFaces setup with an index.jsp which a4j:includes another piece of code which contains a rich:dataTable.

It initially renders fine, and selecting an item on the index.jsp's dropDown list and clicking the 'Retrieve' a4j:commandButton uses the backing bean's setChosen method to do it's bidding on the back end. The backing bean updates class members whose getters are then called by the model reading elements in a separate file content.jsp which is a4j:included. My updated tabPanel appears.

I can see output in the eclipse console. But when I hit the button again, nothing happens. Nothing in the tomcat 6.0 log and nothing on the console.

EDIT1 Narrowing the problem down to my content.jsp file and not the above index.jsp code, I've found that a rich:dataTable element is the problem. When I remove just this element from the content.jsp, I can reclick on the Retrieve button over and over and it reloads my tab panel. As soon as I put it in, the first click is ok, and then the button will click, but nothing occurs and the button doesn't unclick back out.

The method that provides the rich:dataTable with data shouldn't be suspicious as it works at least the first time, but it only performs some xpath routines and returns a ArrayList<MyDataList>.

Given the edit, can anyone now suggest how to use rich:dataTable so that it doesn't cause any trouble? The element is inside a rich:tabPanel which is inside an h:form but that is all.

Thanks

EDIT2: In response to a commented request below, the following is the full affected code listing as brief as will reproduce the problem. @Damo, please note the a4j:commandButton and rich:dataTable are in different files as the latter is in the jsp file which is a4j:included. Also note the <%@ taglib uri=... references have been removed from both files.

index.jsp:

<f:loadBundle basename="messages" var="msg" />

<f:view>
    <rich:page pageTitle="MyTitle" markupType="xhtml">
    <h:outputText id="setup" value="#{MyBacking.setup}" />
        <rich:toolBar height="35" itemSeparator="line">
            <rich:toolBarGroup location="left">
                <a4j:form>
                    <a4j:outputPanel id="panel">
                        <h:outputText style="text-align: center" value="Select " />
                        <h:selectOneMenu id="nodes" value="#{MyBacking.chosen}">
                            <f:selectItems value="#{MyBacking.nodes}" />
                        </h:selectOneMenu>
                        <a4j:commandButton value="Retrieve"
                            reRender="panel,contentPanel,currNode,lastOp"
                            onclick="this.disabled=true" oncomplete="this.disabled=false" />
                    </a4j:outputPanel>
                </a4j:form>
            </rich:toolBarGroup>
        </rich:toolBar>

        <rich:panel>
            <h:panelGroup layout="block" id="contentPanel">
                <a4j:include viewId="#{MyBacking.viewId}">
                    <f:param name="targetIdParam" value="content" />
                </a4j:include>
            </h:panelGroup>
        </rich:panel>
    </rich:page>
</f:view>

a4j:included content.jsp:

<h:form id="myConfig">
    <rich:tabPanel switchType="client" rendered="true">
        <rich:tab styleClass="tab" label="Connections">
            <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                cellpadding="0" cellspacing="0" width="100%" border="0" var="item"
                value="#{MyBacking.DataList}">
                <rich:column style="text-align:center" width="150px">
                    <h:outputText styleClass="txtBold"
                        value="#{item.info}:#{item.other}" />
                </rich:column>
            </rich:dataTable>
        </rich:tab>
    </rich:tabPanel>
</h:form>

Thanks very much indeed for looking at this.

EDIT3 As requested, I've tried encapsulating the a4j:include within an h:form. In order for the included content to avoid nesting an h:form, I replaced the enclosing h:form tag in content.jsp with an h:panelGrid. When I reran this the second click on the a4j:commandButton still caused a hang, but I checked with firebug and a POST http://localhost:8888/index.jsf 200 13ms occurred but the response was empty. Does this help?

+3  A: 

I often experience this when I reRender commandButtons/Links.

Your a4j:form is in effect reRendering itself. Try changing it to something like this:

<a4j:form>
    <a4j:outputPanel id="panel">
        <h:outputText style="text-align: center" value="Select " />
        <h:selectOneMenu id="mySelect" value="#{MyBacking.chosen}">
            <f:selectItems value="#{MyBacking.myList}" />
        </h:selectOneMenu>
    </a4j:outputPanel>
    <a4j:commandButton value="Retrieve" reRender="panel"/>
</a4j:form>

UPDATE: move your h:form to enclose the a4j:include. Pretty sure that it needs a form and of course you can't nest forms.

Damo
Good response, but it doesn't work. If I use an a4j:outputPanel, could I not ignore the need for an a4j:form?
Mark Lewis
it should work - again, check your js console (+1)
Bozho
Interesting. The button was starting a cascade of backing bean work to do different things. I've narrowed it down so that it works as above fine unless the bean updates an element which is a4j:included into the above page with contains a `rich:dataTable`. i don't even need to reRender the a4j:include to reveal the content of the include. do i need faces-config.xml navigation content for a4j:included content? i'll ask another specific question about this.
Mark Lewis
Sorry Damo, I've unchecked the tick, as it was that or reask essentially the same question and get flamed. I've not run the original code without the dataTable element so I guess it's possible I had two problems, but essentially I've still got the problem nonetheless. Question has a new title.
Mark Lewis
Updated question to include `h:form` to no avail.
Mark Lewis
A: 

The fix was to install a facelets jar. See here.

Mark Lewis