[richfaces-issues] [JBoss JIRA] Commented: (RF-8470) MenuItems doesn't work after Ajax-Requests

Dustin Peterson (JIRA) jira-events at lists.jboss.org
Thu Mar 4 07:48:10 EST 2010


    [ https://jira.jboss.org/jira/browse/RF-8470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12518087#action_12518087 ] 

Dustin Peterson commented on RF-8470:
-------------------------------------

Here's additionally the toolbar creation methods in contentmanager.

    /**
     * Renders the menu toolbar if the reRenderToolbar option is set.
     * @param toolbar reference to the toolbar of the session user
     */
    public void setToolbar(HtmlToolBar toolbar) {
        this.toolbar = toolbar;
        /*
         * only rerender toolbar if the flag is set (if you rerender everytime this method is called, the toolbar won't
         * work)
         */
        if (this.isReRenderToolbar()) {
            logger.debug("Recreate toolbar");
            FacesContext ctx = FacesContext.getCurrentInstance();
            Application app = ctx.getApplication();
            this.toolbar.getChildren().clear();
            ListIterator<AModule> i = this.getModules().listIterator();
            ListIterator<CModulePage> n;
            /*
             * iterate through all modules and add all visible pages to the drop down menu
             */
            while (i.hasNext()) {
                AModule mod = i.next();
                HtmlDropDownMenu menu = new HtmlDropDownMenu();
                menu.setValue(mod.getTitle());
                menu.setEvent("onmouseover");
                menu.setShowDelay(100);
                n = this.getVisiblePages(mod).listIterator();
                /*
                 * iterate through all visible pages and add the defined actionlisteners to the menuitems
                 */
                while (n.hasNext()) {
                    CModulePage item = n.next();
                    HtmlMenuItem entry = new HtmlMenuItem();
                    entry.setSubmitMode("server");
                    entry.setReRender("includewindow");
                    if (item.getIcon() != null) {
                        entry.setIcon("modules/" + mod.getIdentifier() + "/img/" + item.getIcon());
                    }
                    entry.setValue(mod.getPrinter().getValue(item.getTextKey()));
                    if (item.getMethodExpr() != null && item.getMethodExpr().contains("hans")) {
                       MethodExpression mBinding = app.getExpressionFactory().createMethodExpression(
                                FacesContext.getCurrentInstance().getELContext(), "#{" + item.getMethodExpr() + "}",
                                String.class, new Class[] { ActionEvent.class });

                       entry.addActionListener(new MethodExpressionActionListener(mBinding));
                    }
                    MethodExpression mBinding = app.getExpressionFactory().createMethodExpression(
                            FacesContext.getCurrentInstance().getELContext(), "#{contentmanager.accessPage}",
                            String.class, new Class[] {});
                    
                    entry.setActionExpression(mBinding);
                    
                    /*
                     * put the accessPage-data (module,page to access on click) into the data-tag of the menuitem
                     */
                    UIParameter modulename = new UIParameter();
                    UIParameter link = new UIParameter();
                    link.setName("link");
                    modulename.setName("modulename");
                    link.setValue(item.getLink());
                    modulename.setValue(mod.getIdentifier());
                    entry.getChildren().add(link);
                    entry.getChildren().add(modulename);
                    menu.getChildren().add(entry);
                }
                /*
                 * only add the drop down menu for the module if there is at least one menuitem
                 */
                if (menu.getChildCount() > 0) {
                    this.toolbar.getChildren().add(menu);
                }
            }
        }
        this.setReRenderToolbar(false);
    }
    
    /**
     * Returns the current rendered toolbar or renders a new toolbar if no toolbar does exist.
     * @return rendered toolbar
     */
    public HtmlToolBar getToolbar() {
        /*
         * only rerender toolbar (setToolbar) if the rerendering
         * has requested, e.g. by changing locale or login
         */
        if(this.isReRenderToolbar() || this.toolbar == null){
            this.toolbar = new HtmlToolBar();
            this.toolbar.setId("toolbar");
            this.setToolbar(this.toolbar);
            this.refreshRequested = false;
        }
        return this.toolbar;
    }

> MenuItems doesn't work after Ajax-Requests
> ------------------------------------------
>
>                 Key: RF-8470
>                 URL: https://jira.jboss.org/jira/browse/RF-8470
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-menu
>    Affects Versions: 3.3.2.SR1
>         Environment: Windows XP SP3
> Internet Explorer 6, Firefox 3.6, Chrome 4.0, Opera 10.10
> Apache MyFaces 1.2.6
> Richfaces 3.3.2
>            Reporter: Dustin Peterson
>            Assignee: Nick Belaevski
>
> I'm using rich:toolbar in connection with ui:include or a4j:include (the effect is the same).
> The MenuItems below toolbar set variables, which page to include and the include-component includes this page - does work well.
> But if I use e.g. a4j:commandLink or rich:progressBar, the ActionEvents of the MenuItems won't be fired. The JSF Lifecycle is working properly.
> I have to do one request on the toolbar and in the next request everything works fine again, so i have to press the toolbar item twice. 
> It sounds to me like a bug.
> Anyway, the normal JSF commandLink or commandButton does work well and their ActionEvents are fired, so the problem should be anywhere in toolbar, menuitem or dropdownmenu.
> Here's the code of the main page:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html 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">
> 	<f:view locale="#{contentmanager.locale}" id="mainview">
> 		<head>
> 			<title><h:outputText value="#{msg.title}" /></title>
> 			<link rel="stylesheet" href="style.css" />
> 			<ui:insert name="script" />
> 		</head>
> 		<f:loadBundle basename="local.bundle"
> 			var="msg" />
> 		<f:loadBundle basename="#{contentmanager.currentResourcePath}"
> 			var="msgmod" />
> 		<body>
> 			<rich:panel headerClass="panelHeader" bodyClass="panelBody">
> 				<f:facet name="header">
> 					<h:form>
> 						<rich:toolBar styleClass="toolbar" width="100%"
> 							binding="#{contentmanager.toolbar}" contentClass="toolbaritem"
> 							itemSeparator="line" id="toolbar">
> 							<rich:toolBarGroup location="right">
> 								<h:commandLink action="#{contentmanager.changeCurrentLocale}">
> 									<f:param name="locale" value="de" />
> 									<h:graphicImage styleClass="language"
> 										value="#{contentmanager.iconGerman}" />
> 								</h:commandLink>
> 								<h:commandLink action="#{contentmanager.changeCurrentLocale}">
> 									<f:param name="locale" value="en" />
> 									<h:graphicImage styleClass="language"
> 										value="#{contentmanager.iconEnglish}" />
> 								</h:commandLink>
> 							</rich:toolBarGroup>
> 						</rich:toolBar>
> 					</h:form>
> 				</f:facet>
> 				<h:panelGroup rendered="#{contentmanager.moduleConfigurationChanged}">
> 					<br /><p class="text"><h:graphicImage value="#{contentmanager.iconNewMail}" style="height:24px;vertical-align:middle;align:left" /><h:outputText styleClass="richpadding" value="#{msg.moduleconfigchanged}" /></p>
> 				</h:panelGroup>
> 				<h:messages styleClass="removeliststyle" errorClass="error"
> 					infoClass="success" />
> 				<!-- INCLUDED PAGE -->
> 				<ui:include src="#{contentmanager.currentInclude}" id="includewindow"/>
> 				<br />
> 			</rich:panel>
> 		</body>
> 	</f:view>
> </html>
> In the backing bean, the toolbar items are created with the specific MenuItems and ActionListeners on the MenuItems.
> For example if I click that link:
> <a4j:commandLink actionListener="#{module.analysation}" reRender="dataGroup">
> 					<f:param name="id" value="#{module.identifier}" />
> 					<h:outputText
> 						value="test" />
> 					<rich:componentControl for="dataPanel" operation="show"
> 						event="onclick" />
> 				</a4j:commandLink>
> dataGroup is a panelGroup in the modalPanel.
> After clicking this link and the corresponding hide-link for the modalpanel, the next time I click on a menuitem the ActionEvents aren't fired.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list