0

I'm facing a problem with poll request, the first call is ok and the second is loosing the request parameter. Below is the code:

<h:form id="form">  

    <p:poll interval="10" listener="${emsstatbean.getEmsStat_list(request.getParameter('para'))}" update="emstatTable" />  
    <p:dataTable id="emstatTable" var="emsstat" value="${emsstatbean.getEmsStat_list(request.getParameter('para'))}" emptyMessage="No statistic found with given criteria" styleClass="table table-striped table-bordered table-hover" >

    <p:column headerText="Server Hostname" >
        <h:outputText value="#{emsstat.id.timeStamp}" />
    </p:column>

    <p:column  headerText="Os name" >
        <h:outputText value="#{emsstat.upTime}" />
    </p:column>        

    <p:column  headerText="Os name" >
        <h:outputText value="${emsstat.state}" />
    </p:column>        

    </p:dataTable>  
</h:form>                                      

and this is the bean class:

@ManagedBean(name = "emsstatbean")
public class EmsStatBean implements Serializable 
{

    public List<TibcoEmsStat> getEmsStat_list(int p) 
    {
        return service.listEmsStats(p);
    }

    @ManagedProperty("#{emsStatService}")
    EmsStatService service;

    @PostConstruct
    public void init() 
    {
    }

    public void setService(EmsStatService service) 
    {
        this.service = service;
    }
}

This is the URL called: content/public/TibcoEmsStat.xhtml?para=254 So when I paste that on browsers I'm getting the data table with all rows, but when I wait 10 sec I don't see content and I get "No statistic" found with given criteria, because parameter is empty.

Can you please help me to understand where is the issue?

NarendraR
  • 7,577
  • 10
  • 44
  • 82
Matt Vegas
  • 453
  • 5
  • 17
  • Possible duplicate of [Retaining GET request query string parameters on JSF form submit](https://stackoverflow.com/questions/17734230/retaining-get-request-query-string-parameters-on-jsf-form-submit) – Kukeltje Aug 02 '17 at 06:49
  • It most likely is already loosing it in the first ajax call. Your real fitst call is not an ajax call but a plain GET – Kukeltje Aug 02 '17 at 06:50
  • @Kukeltje i got that, but i need to refresh an object without doing a GET, how can i achieve, so in that case i can save the para value is some variable. thanks for the help – Matt Vegas Aug 02 '17 at 08:03

1 Answers1

0

this is how i fixed after reviewing some suggested link

added to the bean:

@ViewScoped

and a variable to store the id

public int ems_inst;

public int getEms_inst() {
    return ems_inst;
}

public void setEms_inst(int ems_inst) {
    this.ems_inst = ems_inst;
}

on the xhtml i did:

<f:metadata>
<f:viewParam name="ems_inst" value="#{emsstatbean.ems_inst}" />
</f:metadata>
            <h:form id="form">  

<p:poll interval="10"   
    listener="${emsstatbean.getEmsStat_list(emsstatbean.ems_inst)}" update="emstatTable" />  
<p:dataTable id="emstatTable" var="emsstat" value="${emsstatbean.getEmsStat_list(emsstatbean.ems_inst)}"

all now is working fine

thanks

Matt Vegas
  • 453
  • 5
  • 17