0
votes

I am having a JSF application which creates and presents about 50 reports. These reports are rendered PNGs and under the pictures a table is displayed.

This table uses a RichFaces 4 togglePanel with switchType="client". The togglePanel is just for collapsing and expanding the table.

<h:form>
        <rich:togglePanel id="#{param.reportWrapper}_togglePanel"
            stateOrder="opened,closed" activeItem="opened" switchType="client">
            <rich:togglePanelItem name="closed">
                <h:panelGroup>
                    <div class="myclass">
                        <ul class="container-icons">
                            <li>
                                <h:commandLink styleClass="container-max" value="maximieren">
                                        <rich:toggleControl targetPanel="#{param.reportWrapper}_togglePanel" targetItem="@next" />
                                </h:commandLink>
                            </li>
                        </ul>
                        <h3>My Heading</h3>
                    </div>
                </h:panelGroup>
            </rich:togglePanelItem>
            <rich:togglePanelItem name="opened">
                <h:panelGroup>
                    <div class="myclass">
                        <ul class="container-icons">
                            <li>
                                <h:commandLink styleClass="container-min" value="minimieren">
                                        <rich:toggleControl targetPanel="#{param.reportWrapper}_togglePanel" targetItem="@prev" />
                                </h:commandLink>
                            </li>
                        </ul>
                        <h3>Another Heading</h3>
                        <div class="scrolling-table-content">
                            <rich:dataTable>
                                      // ...
                            </rich:dataTable>
                        </div>
                    </div>
                </h:panelGroup>
            </rich:togglePanelItem>
        </rich:togglePanel>
        </h:form>

The problem is, that I sometimes get a ViewExpiredExceptions when the reports are loaded. My numberOfLogicalViews and numberOfViewsInSession is 14. I dont want to set it to 50, because of memory issues and because it should not be necessary as only one report is really shown at the same time.

I tried to remove the h:form tags, which are seen as logicalView. In my opinion the togglePanel is not the item, which needs the form because it's switch type is client (not server and ajax, which need form tags). But the command link does need the form tag, because if I remove it, an error occurs saying "this link is disabled as it is not nested within a jsf form".

So I tried to replace the commandLink with a commandButton. This worked fine first and the form wasnt necessary anymore. But somehow the behaviour is completely random now. Sometimes the tables can be expanded, sometimes nothing happens when i click the expand button. When i add form tags again, it works fine, but doesnt solve my ViewExpiredException.

Hope, somebody can help me out here...

Thanks for your help!

Buntspecht

2
You may want to use <rich:collapsiblePanel> if you need something collapsed. But I only see 2 commandLinks, how is that too many?Makhiel
It is too many, because this is just an example for one of the 50 reports which are loaded. The currently selected report is displayed in a bigger frame and the other reports are loaded as smaller thumbnails as a kind of preview. So all in all there are about 100 commandLinks then.buntspecht
And do you need to communicate with the server? Because then you wouldn't need the commandlinks.Makhiel
No, as they are just to show or hide my tables. But what can I use instead? I tried to use commandButtons instead but it seems like they also need to be embedded in h:form tags to work properly.buntspecht

2 Answers

0
votes

If you only need to switch the panel you can use <a4j:commandLink> that lets you limit the execution scope (so it won't submit the whole form). Or you can remove the command components altogether and just use JavaScript API of the togglePanel:

<a onclick="#{rich:component('panelId')}.switchToItem(#{rich:component('panelId')}.nextItem())">Next</a>
0
votes

Thank you very much for your help Makhiel. I finally managed to solve the problem with the commandButtons solution. I can't explain why, but the IDs of my togglePanelItems got duplicated in the different reports.

Giving every togglePanelItem a unique ID like

<rich:togglePanelItem name="closed" id="#{param.reportWrapper}_opened">

and

<rich:togglePanelItem name="opened" id="#{param.reportWrapper}_closed">

solved the problem...

So now we got rid of all the h:form tags and thus have about 50 logical views less! :)