java - How to ajax jsf 2 outputLink - Stack Overflow

I want to make a webpage that is working on ajax(everything ajax). I mean.. whenever you click a link(I

I want to make a webpage that is working on ajax(everything ajax). I mean.. whenever you click a link(I refer to < h:outputLink ...> ) to change a certain div using data from another link.

For example:

<h:outputLink value="/page.jsf" onclick="myfunction(this); return false;">
    My page
</h:outputLink>

page.jsf is a normal jsf page... displayed using a page layout.xhtml like:

<ui:position template="/layout.xhtml">
    <ui:define name="main">
         //my content here
    </ui:define>
</ui:position>

Is this possible? Is this possible, using a servlet to take only fragments from a specific jsf?

My last solution is to use jquery.load function...

Regards

I want to make a webpage that is working on ajax(everything ajax). I mean.. whenever you click a link(I refer to < h:outputLink ...> ) to change a certain div using data from another link.

For example:

<h:outputLink value="/page.jsf" onclick="myfunction(this); return false;">
    My page
</h:outputLink>

page.jsf is a normal jsf page... displayed using a page layout.xhtml like:

<ui:position template="/layout.xhtml">
    <ui:define name="main">
         //my content here
    </ui:define>
</ui:position>

Is this possible? Is this possible, using a servlet to take only fragments from a specific jsf?

My last solution is to use jquery.load function...

Regards

Share Improve this question edited Oct 12, 2011 at 10:56 Alex asked Oct 12, 2011 at 9:14 AlexAlex 2,1463 gold badges25 silver badges48 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

<h:link> and <h:outputLink> cannot be ajaxified. All JSF2 ajax requests are per specification POST requests. You need a <h:form> with a <h:mandLink>.

You could use the following construct:

<h:form>
    <f:ajax render=":include">
        <h:mandLink value="Home" action="#{menuManager.setPage('home')}" /><br />
        <h:mandLink value="FAQ" action="#{menuManager.setPage('faq')}" /><br />
        <h:mandLink value="Contact" action="#{menuManager.setPage('contact')}" /><br />
    </f:ajax>
</h:form>
<h:panelGroup id="include">
    <ui:include src="#{menuManager.page}.xhtml" />
</h:panelGroup>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745576435a4633990.html

相关推荐

  • java - How to ajax jsf 2 outputLink - Stack Overflow

    I want to make a webpage that is working on ajax(everything ajax). I mean.. whenever you click a link(I

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信