1 2 Previous Next 22 Replies Latest reply on Nov 9, 2015 12:51 PM by Gopal Herkal

    Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include

    maze_fr Newbie

      Hello everybody,

       

      As I found many topics about the same problems and tried every solution I found and that nothing worked, then I decided to ask for my problems here.

      Maybe I dodn't found the good topic to solve my problems and I appologize for the waste of time if it's the case.

       

      I use Richfaces 4.0.0 Final + Mojarra 2.0.3 + JBoss 6.1.0.Final.

       

      So, here is my case :

      • I have a global body template for all my site.
      • I use a richer template for some pages that have a lot in commun, which use global body template.
      • I load the content with a dynamic ui:include with navigation of the menu (that is in the richer template).

       

      Here is the summed up code architecture :

      Global body : html > f:view > h:body > div > table > tr > td > ui:insert

      • Richer body template from global body : ui:composition > ui:define > rich:panel > table > tr > td > div > a4j:outputPanel > ui:include
        • Content page : ui:composition > f:view > rich:panel > ui:include
          • Reused content : ui:composition >
            • h:form > rich:dataTable > a4j:commandLink
            • my popup tag : ui:composition > h:form > a4j:outputPanel > rich:popupPanel > table > tr > td > ui:decorate > a4j:commandButton

       

      I konw, it looks like a matriochka...

       

      All my pages (templates, contents, tags, etc) have <h:head />, as I read this problem somewhere.

      All my pages have :

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <xxx:the_good_tag 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">

       

      Detailed mechanisms :

      • In the richer body, when I click on the rich:panelMenuItem of the rich:panelMenu, the bean is updated and a4j:outputPanel is rerender to refresh the dynamic include.
      • When I click on reused content edit link, it shows the popup and refresh the content. On second time click, the popup is correctly refreshed.
      • When I click on popup button to save the modifications, it hides the popup (it works) and refresh the rich:dataTable, theoricaly... but I traced the action and the logs shows it doesn't fire it.
      • If I try to show directly the content page and use the popop, everything works fine... but I prefer to use Ajax better than reload the entire page...

       

      Here are the problems :

      • When I click on a button, the action launches only after second click : the first click never works, but everything is OK afterwards.
        I found that "javax.faces.PARTIAL_STATE_SAVING" at false in "web.xml" should solve that problem, but it doesn't.
      • One of my contents has an hidden edit popup (to edit the current line) that I use as a tag.
        When I click (so on second time) to show the popop, the content is refreshed, so this is OK (excepted that it's on second click...).
        But when I click on "save" button, the popup go hidden again as it must but nothing happens in the Java, the action is not launched.

       

      I thank anybody who could help me about my problems.

      If anything is missing to help me correctly, just ask.

        • 1. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
          Brendan Healey Master

          There were some fixes in Mojarra 2.1 related to using 'dynamic ui:include', I'd suggest upgrading

          and having another try.

          • 2. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
            maze_fr Newbie

            Yeah... the problem is I don't decide of the version used...
            But I will try to convince the person who does

            • 3. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
              Brendan Healey Master

              Perhaps if you could setup a new test environment with 2.1 as the only change, and it then starts

              working, it would be pursuasive. If you've not already come across it the mojarra jira discussion

              (extremely lengthy) is here: http://java.net/jira/browse/JAVASERVERFACES-1313.

               

              I don't know if you've tried it but I've found 2.1.* to be only more reliable than earlier versions (it was

              a bug fix release after all). The one annoying problem that I think was introduced in 2.1 is the "The

              form component needs to have a UIForm in its ancestry..." message. Intended to highlight if a

              command component is not inside a form, it gets a bit confused with complex page structures

              with templates, composite components and ui:includes and suchlike. But this only shows in

              development mode.

              • 4. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                jlpktnst Newbie

                Anyone had success using 2.1? The latest glassfish 3.1.1 has 2.1.3 rc something mojarra integrated anyway. I am not sure though if that gets used. Is there a way to check? I suspect though that it gets used and ui:include still doesn't work in a useful manner.

                 

                Is there any ui:include workaround that would let us keep stuff neat?

                • 5. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                  Brendan Healey Master

                  Hi, I use 2.1.3 with no problems to report. The only way I've found to check the version is from the

                  server log, you should see something like this for each applcation deployed:

                   

                  INFO: Initializing Mojarra 2.1.3 (FCS b02) for context '/core-demo-4.0.0.Final'

                  • 6. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                    maze_fr Newbie

                    Hello guys,

                     

                    I tried Mojarra 2.1.3 and still the same : I need to click twice to have an action performed, etc like before.

                     

                    It works if I call directly the page containing the popup (the dynamicaly included page).

                    But I found out that when I call directly a clean page containing the popup with template templated (my rendered page if i wouldn't use ajax), it doesn't work either.

                     

                    After very big investigation (my boss is on the nerves for delay...), I found out the problem.

                    As long as the ui:include is surrendered by a a4j:outputPanel at any level, the popup doesn't work.

                    I remove that (and so I stop using the interest of ajax), then it works.

                    Even in a non dynamicaly updated page that show directly the content I want, the a4j:outputPanel forbid my a4j:commandButton to work correctly.

                     

                    If anyone has an idea on how to make my a4j:commandButton work in an included page inside an a4j:outputPanel, I would be very thankful.

                    Else, I would be also very thankful for a solution to replace the buggy behaviour of a4j:outputPanel.

                    • 7. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                      jlpktnst Newbie

                      Yes, Mojarra is broken. Richfaces is broken. I am just now rewriting my templates to do the old-style link navigation. I hear f:ajax works properly, but I tested it on a div and it does not. So I guess Mojarra is broken like hell regarding includes. What were they thinking? That we will have the entire app in one file? Anyone tried the other JSF implementation (myfaces)? Is that one less broken?

                      • 8. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                        Brendan Healey Master

                        I suppose that where you'd want to have something like this:

                         

                        <ui:include src="#{myBean.selectedSport}.xhtml"/>

                         

                        You could replace it with this:

                         

                        <h:panelGroup rendered="#{myBean.selectedSport == 'football'}">

                          <ui:include src="football.xhtml"/>

                        </h:panelGroup>

                         

                        <h:panelGroup rendered="#{myBean.selectedSport == 'tennis'}">

                        <ui:include src="tennis.xhtml"/>

                        </h:panelGroup>

                         

                        etc...

                         

                        Obviously a bit of a nuisance if you've got 100 "sports" to support but at least it doesn't include everything

                        all the time so should improve page load speed?

                        • 9. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                          maze_fr Newbie

                          I think your solution includes everything but hides things with "rendered=false" and so the page is very heavy.

                          • 10. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                            Brendan Healey Master

                            >>hides things with "rendered=false"

                             

                            exactly. So in my hypothetical example, if you have 100 sports, and each file you ui:include averages 50 lines

                            of markup, you could potentially be loading 5000 lines onto the client every time you load the page. At least

                            with this approach you're only loading what you need. The negative is that because of the 'dynamic ui:include'

                            problems that you and I have both experienced, you need to maintain a list of h:panelGroup rendered= tags

                            for each file that you wish to conditionally include.

                             

                            It's not an ideal solution but it's the best that I can find right now.

                            • 11. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                              Parsi Kumar Newbie

                              I had similar kind of problem, the change I made to solve this was having a single form. I had different h:form for each page, but now have only one h:form for everything.

                               

                              Try to use following options as applicable

                              execute="@form"  or "@this" or "@none"

                              limitRender="true"

                               

                               

                              Other suggestion, if you have to have ui:include for each page then the page name get be fetched dynamically basing on the selection made by the user. And following code can be used to get the page name to be included.

                               

                              <a4j:outputPanel id="somePanelId" layout="block" ajaxRendered="true">

                                                  <ui:include src="#{someBean.somePageName}" />

                              </a4j:outputPanel>

                               

                              Versions:

                              Mojarra version: 2.1.3

                              RichFaces 4.0.0 Final

                               

                              I hope it helps.

                              • 12. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                                maze_fr Newbie

                                I used exactly the same piece of code to dynamicaly render my ui:include.

                                I realy don't like the idea to have one big form...

                                Did you try to use a4j:region and execute="@region" ? In that way, if it works, one big form could be acceptable.

                                • 13. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                                  jlpktnst Newbie

                                  Hum, actually, I had problems whenever I tried to load anything that had an include in it using ajax.

                                   

                                  After doing render="form" ajax request a form would rerender but I would always have to doubleclick stuff. Regardless of static/dynamic include. Since I cannot live without includes I just moved the app to classic navigation and it works that way. When I refresh stuff I just classically refresh whole page. Tabs I set to "server" mode... it "works" now. Ajax only in components.

                                  • 14. Re: Richfaces 4.0.0 + Mojarra 2.0.3 => Ajax problems in dynamic ui:include
                                    Parsi Kumar Newbie

                                    Finally, I found a temporary fix for the problems when using multile <h:form>, multile <rich:popupPanel> and multiple <ui:include> tags.

                                     

                                    Scenario: I have a main page and depending on the user events (button click or any event) a popup is shown. For different user selection in the main form, there can be different popups shown, but in this example I have code for one popup only.

                                    ---------------------------------------------------------------------------------------

                                    Page: MainPage.xhtml

                                    <ui:composition ---

                                    <ui:define name="body">

                                     

                                    <h:form id="mainFormID">

                                    ----

                                    ---

                                    </h:form>

                                     

                                    <rich:popupPanel id="reviewPopupID" minHeight="500" minWidth="700">

                                    <h:form id="reviewFormID">

                                         <a4j:ajaxoutputPanel id="reviewPanelID" layout="block" ajaxRendered="true">

                                              <ui:include src="./PopupPage.xhtml" />

                                         </a4j:outputPanel>

                                    </h:form>

                                    </rich:popupPanel>

                                     

                                    </ui:define>

                                    </ui:composition >

                                    ---------------------------------------------------------------------------------------

                                    Page: PopupPage.xhtml

                                     

                                    <ui:composition ---

                                         <rich:panel>

                                              ----

                                              -----

                                              -----

                                         </rich:panel>

                                    </<ui:composition>

                                     

                                     

                                    Note: PopupPage.xhtml can have all the code which has to be shown in the popup panel. But make sure that all the code is inside a <ui:composition> tag. And no need of any <html> or <body> tags in PopupPage.xhtml.

                                    ---------------------------------------------------------------------------------------

                                     

                                    Code for showing the popup

                                     

                                    <a4j:commandButton value="Submit"

                                                    action="#{SomeBean.submitMethod()}"

                                                    oncomplete="#{rich:component('reviewPopupID')}.show()"

                                                    render="reviewPanelID" limitRender="true" />

                                     

                                     

                                    Versions:

                                    Mojarra version: 2.1.3

                                    RichFaces 4.0.0 Final

                                     

                                    I hope it is helpful.

                                    1 2 Previous Next