Just migrated from jboss 7.1 to wildfly 16 and PrimeFaces 4.0 to 6.2.
As I know PrimeFaces uses ajax with its elements such p:commandLink, p:commandButton, etc.
I have:
<p:commandLink action="#{exampleBean.redirrectSomewhere}">
labelName
</p:commandLink>
After tapping at the commandLink nothing is happening, but if I add ajax='false' as an attribute, it is going to work fine.
Is there some way to get redirected using ajax?
Ask for extra information.
This is a known issue (at least to me). Use process="#this" to make sure that the ajax updates current component instead of the whole view. You can then remove ajax="false".
Related
I need to use InputTextarea PrimeFaces component, wich allow use autocomplete mechanism between text. All works great, except for p:statusAjax, when I'm typing, my loading var animation blocks screen.
I resolve this for AutoComplete PrimeFaces component by adding next lines between p:autoComplete:
<p:ajax event="query" global="false"/>
But when I try put this line between p:inputTextArea JSF shows error:
javax.servlet.ServletException: /notificaciones/edit.xhtml #162,50 Event:query is not supported.
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)...
I've read PrimeFaces User Guide but for inputTextArea component there is no Ajax Behavior Section.
So, how can I know which event is firing when autocomplete method executed on p:inputTextArea
Most of the time, the documentation is up-to-date so most likely there is no ajax event. But to be sure, you can always check the javascript source and/or the java source of the component (the source is open and freely accessible).
You can always try without an event name to see if ajax is supported at all since all (most?) components have a default event.
I'm in a good mood and A quick check for you in the java source and the forms.js javascript source of 6.1 (which contains the js for this component and which is split in its own forms.inputtextarea.js in the 6.1.3 Elite and upcoming 6.2 release) does not show any ajax events being used, so I think you are out of luck on this and need to file an enhancement request in github
Recently I started using prettyfaces with my web application which uses jsf1.x. While testing I realized that action methods for h:commandButton and h:commandLink is not getting called. Upon searching on the net, I found a link on this site where some suggested to use <f:ajax render="#form" /> it should be ok. Since f:ajax is available in JSF2.x, so I was thinking how can I find the equivalent of <f:ajax render="#form" /> in Jsf1.x
Any help be greatly appreciated as I am completely stuck due to this.
Thanks,
Neeraj
There is something seriously wrong if the actions of the h:commandButton and h:commandLink are not being called anymore. Maybe it's something easy like failed validation, which cancels the call of the action (try immediate="true" in your button/links). If it's not, then you should try to find and fix what causes this instead of switching to Ajax functionality.
As already pointed out, you may use a4j which is delivered with RichFaces 3 and works also with JSF 1.
BUT you cannot throw away this basic functionality. Using Ajax only you will run into a lot of problems later on. a4j:ajax might be the equivalent of f:ajax, but it's certainly not equivalent to the standard post-action functionality.
One common usecase would be a PDF to be displayed. This isn't possible with an Ajax partial-update.
Does anyone know how I can upload multiple files with primefaces (http://www.primefaces.org/showcase/ui/fileUploadMultiple.jsf) when I click my own submit button? The upload-button there should not be visible, because I want to chose the upload-time on my own.
I have multiple pm-fileupload components in my document, so I want to upload them all together.
is there a way? Or must I use the old browser-upload?
Use multiple <p:fileUpload mode="simple"> generated by a <ui:repeat> or <h:dataTable>.
The <p:fileUpload mode="advanced"> indeed isn't suitable for this requirement, or you must turn on automatic immediate upload on select by adding auto="true".
First of all I'm still learning the structure and how it works.
I searched around the web to get an suitable and easy answer to the following question:
Is there a way to regonize all other basic ajax events, like hovering and clicking on Primefaces Components?
For example, i would know the event which get invoked if you click on the previous or next button on an <p:schedule>. The documentation says there are only "dateSelect, eventMove, eventResize" and "eventSelect" as callable ajax events. But this is not enough, if you want to build an complex application and you combine an <p:calendar> with an <p:schedule>. There you need to know when the schedule switches the month or year.
I hope someone can give me an clear and understandable answer to this.
Thanks and best regards.
Since you did not specify what event you need, your answer is going to be as clear as the question.
The primefaces objects can only recognize the events they are programmed to. If you need to get a specific type of event, you can:
1) see if the primefaces support that event. put it in a <p:ajax tag, and see if it works.
2) see if the standard JSF ajax API support it.
3) If all else fails, you can try to put a jQuery script along with the page, to handle the event and make a call from the client side.
The <p:calendar and <p:schedule makes heavy use of jQuery plugins to render it, I doubt you can get the events on the month selector or anything else in the rendered interface without client-side jquery.
I have a selectonlistbox and I want to reload a panelgrid everytime the selectbox selection is made/changed. I am try to use just jsf 1.2.
I know it can be done easily using a4j or faces 2, but if anyone knows any good way to achieve this in jsf 1.2, I would really appreciate it.
A simple example would help a lot too.
Thanks
You basically need to create a custom Ajax aware ViewHandler and a custom XML ResponseWriter and custom tags which generates the desired JavaScript code to perform the XMLHttpRequest works and HTML DOM manipulation. This is also what most of those 3rd party JSF 1.x component libraries have done. They are all open source, so you could just take a peek in its source code to learn-by-example how they did it. It's for a starter after all however not a trivial job as it requires a solid knowledge of how exactly HTTP, HTML DOM, JavaScript and XMLHttpRequest works. A little mistake is quickly made and it would for a starter take ages to find and really understand it.
Your best bet is really either adopting an ajax capable component library for JSF 1.2 (e.g. RichFaces 3.x which includes Ajax4jsf), or just migrating to JSF 2.0 (JSF 1.2 is over 6 years old already and JSF 2.0 was introduced almost 3 years ago already; JSF 1.x is basically history).
This particular functional requirement can however also be done without ajax, albeit somewhat clumsy, certainly if form validation plays a role. Here's a basic kickoff example, it's a matter of just instructing JavaScript to submit the parent form on change of the dropdown list:
<h:form>
<h:selectOneMenu value="#{bean.selected}" onchange="this.form.submit()">
<f:selectItem itemValue="one" />
<f:selectItem itemValue="two" />
<f:selectItem itemValue="three" />
</h:selectOneMenu>
<h:panelGroup rendered="#{bean.selected == 'one'}">
One was selected.
</h:panelGroup>
<h:panelGroup rendered="#{bean.selected == 'two'}">
Two was selected.
</h:panelGroup>
<h:panelGroup rendered="#{bean.selected == 'three'}">
Trree was selected.
</h:panelGroup>
</h:form>
This will submit the whole form synchronously on change of the dropdown list, as if you pressed a submit button. However, as said, if you're performing validation elsewhere in the same form, you'd have to bring in quite some hacks with immediate="true" and valueChangeListener to prevent validation of all other form elements. See also Populate child menus for some detailed examples.
A completely different alternative is to just render everything to the HTML response and hide it using CSS display:none and then toggle the display using JavaScript element.style.display in some JS function which is referenced in onchange attribute.
I think better option is migrate to JSF 2. If you want to do it with JSF 1.2, use some JS libraries like JQuery or prototype and call your JS function on the event and call AJAX updater with the URL to the template page with panel grid and the logic (eg: /mypanaelGrid.jsf).