action in p:commandLink rendered after ajax

UI Components for JSF
Post Reply
peter
Posts: 27
Joined: 10 Mar 2010, 16:18

09 Apr 2010, 14:41

Hello everyone! Recently i faced a problem with a commandLink. I have got two commandLinks on page. First is rendered normally, while page is loading.Second commandLink is rendered after ajax request invoked by click on the first one. The first commandLink invokes action method, which works fine. The second one should invoke another method (i tried with action and actionListener) but it does not.Why? Am i missing something? Below is my code.
bean class

Code: Select all

package pl.comfortel.beans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

@ManagedBean
@RequestScoped
public class Page {

    boolean renderLink;    

    public boolean isRenderLink() {
        return renderLink; }

    public void setRenderLink(boolean renderLink) {
        this.renderLink = renderLink; }

    public Page(){}

    public void actionMethod(ActionEvent e){
        String a = "a";  }

    public void setRenderLink(){
        this.renderLink = true;   }

}//end of Page
jsf page

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!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:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form id="form">
            <p:commandLink action="#{page.setRenderLink}"
                           ajax="true"
                           update="form">
               render link
            </p:commandLink>
            
           <p:ajaxStatus style="text-align: center;">
                <f:facet name="start">
                     Loading...
                </f:facet>
                <f:facet name="error">
                    error
                </f:facet>
                <f:facet name="complete">
                    complete
                </f:facet>
            </p:ajaxStatus>

            <p:commandLink actionListener="#{page.actionMethod}"
                           rendered="#{page.renderLink}" >
                link
            </p:commandLink>
        </h:form>
    </h:body>
</html>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 59 guests