jsf - How can I maintain param on ajax call? -
whenever create ajax call, url param expires. workaround have done pass param request within every button in:
<p:commandlink value="submit" actionlistener="#{mybean.dosomething}"> <f:param name="foo" value="#{mybean.bar}"/> </p:commandlink> however, in scenarios can't above workaround. illustration when i'm using primefaces roweditevent:
<p:ajax event="roweditcancel" listener="#{mybean.oncancel}"/> the param expires when create ajax phone call , results in error before invoking #{mybean.oncance} i'm reading datatable's info param in url.
so how can maintain param value when create such ajax call?
ps: mybean viewscoped
problem extension:
the <o:form> has solved part of problem, can't send params within form dynamic image streaming within table. see following:
<p:datatable value="#{mybean.data}" var="var"> <p:column headertext="thumbnail"> <p:graphicimage value="#{streamer.thumbnail}"> <f:param name="id" value="#{var.id}"/> </p:graphicimage> </p:column> </p:datatable> streamer bean (requestscoped):
public streamedcontent getthumbnail() throws ioexception { facescontext context = facescontext.getcurrentinstance(); if (context.getrenderresponse()) { homecoming new defaultstreamedcontent(); } else { string string = context.getexternalcontext().getrequestparametermap().get("id"); long id = long.parselong(idstring); myimage img = (myimage) service.find(myimage.class, id);//get resource streamedcontent sc = new defaultstreamedcontent(img.getinputstream(), "image/jpg", img.getname()); homecoming sc; } } here string null , parameter not passed resulting in error
register <f:viewparam>
<f:viewparam name="foo" value="#{mybean.bar}" /> and instead of <h:form>, utilize omnifaces <o:form> includeviewparams="true" (which uses under covers custom viewhandler implementation automatically collects view parameters , appends them outcome of getactionurl() method used form action url):
<o:form includeviewparams="true"> ... </o:form> this way view params included in form's action url , hence end request parameters usual way without need fiddle <f:param> , beingness clueless within <p:ajax> (and <f:ajax>).
jsf primefaces
No comments:
Post a Comment