1

In my facelet, I have the below commandLink:

<h:form>
    <p:commandLink id="excelExport" action="#{studentBean.exportReport()}" ajax="false">
         <f:param name="type" value="EXCEL" />
         <p:graphicImage library="img" name="excel.png" width="20" />
    </p:commandLink>
</h:form>

This is what I am having in my backing bean:

@ManagedBean
@RequestScoped
public class StudentBean implements Serializable {
    .............
    @ManagedProperty(value = "#{param.type}")
    private String typeOfExport;

    .............
    public void preRender(ComponentSystemEvent event) {
        System.out.println("Inside prerender");
        if (FacesHelper.isAjaxRequest()) {
            return;
        }
    }
    .............
    public void exportReport() {
        System.out.println("Type of Report is: " + typeOfExport);
    }
}

Now I would like to execute the method exportReport once I click on the commandLink. But what is happening here is that after executing the method, it is going to preRender again. I don't want to render the entire form again. Any idea what mistake I am doing here?

Sudipta Deb
  • 1,040
  • 3
  • 23
  • 43
  • possible duplicate of [preRenderView is called on every ajax request](http://stackoverflow.com/questions/19974950/prerenderview-is-called-on-every-ajax-request) – BalusC Nov 15 '13 at 16:42
  • By the way ... `` doesn't support `ajax` attribute. Perhaps you mixed it with ``? – BalusC Nov 15 '13 at 16:45
  • If you are going to use `` be aware of the attributes you need to use. Please check commandLink Primefaces Showcase [link](http://www.primefaces.org/showcase/ui/commandLink.jsf) to understand what I am talking about. – danRod Nov 15 '13 at 17:08
  • @BalusC: Yes you are correct. I edited the question. And I removed the ajax part. Now I realized the difference between ajax="true" and ajax="false" with RequestBean. Thanks a lot – Sudipta Deb Nov 15 '13 at 17:17
  • with ajax="false" the page refreshes and preRender should be called again. – MrRaymondLee Nov 16 '13 at 06:17

0 Answers0