how to do partial page rendering (center content) with jsf2 templating via ajax (from menu)

前端 未结 2 2004
孤独总比滥情好
孤独总比滥情好 2020-12-18 16:56

i have been struggling getting this to work for 2 weeks, I am trying to merge info from BalusC from these 2 posts to (link1 link2) to achieve partial page rendering of a ce

2条回答
  •  一向
    一向 (楼主)
    2020-12-18 17:16

    i was able to get a design via JSF2/Ajax and richfaces4 (other implementations would be ok I assume) where a left navigation menu item, implemented via templates, is able to render the center content of a template via ajax, preventing a full page refresh, and the flicker effect it has.

    my navigationmenu.xhtml code looks like this

    
    
            
                
                                        
                
                
    ...

    I believe the render=":centerContentDiv,:centerForm" attribute for the a4j:ajax tags can be changed to just render=":centerForm" but have not tested that. I know the both work together however. also, i tried JSF2 ajax tags with white space between the IDs and got errors, so i went to richfaces 4.x's a4j and then could use commas if no space was used.

    now, in order for this to work, each pageX.xhtml file, for example page1.xhtml would need to have , here is an example of page1.xhtml

    
                                            
                
                       
    
                
            
        
    

    one limitation is each view that uses the template must define a otherwise JSF2 will complain it can't find the render target.

    my uiTemplate.xhtml file has code for the header, footer, but the pertinent part that has the navigation and center content defined is as follows

提交回复
热议问题