Primefaces & Spring webflow ajax action call - jsf-2

Are there any way to call spring webflow action at primefaces in p:selectOneMenu?
There are two dependent combobox like as primefaces example.(link) But i want to call action which is defined at webflow transtion therefore i could not use p:ajax with actionlistener.
After search,i tried to use p:remoteCommand to call action.It execute action when parent combo change,but it also give captcha validation error (captcha at same form),therefore i set process="#this" to p:remoteCommand, when i set that i could not execute action.

You should be using remoteCommand to invoke SWF action. If you only want to submit a value for some components you can use process="componentIds" to send only the values of specified components. You may also want 'immediate=true' on the remoteCommand to skip JSF validation - this should stop error messages from captcha validation.
However, in my experience its not a good idea to use SWF actions for tasks like refreshing dependent comboboxes. Primefaces partial rendering is much better suited for this, and does not require gimmicks like SWF tags.
Please post your XML if immediate=true does not work.

Related

ClientSide Validation on PrimeFaces Wizard

For wizard forms, is there any way we can configure the primefaces 4.0 make and client side validation instead of ajax validation?!
According to user guide the ajax validation is built in:
AJAX and Partial Validations
Switching between steps is based on ajax,
meaning each step is loaded dynamically with ajax. Partial validation
is also built-in, by this way when you click next, only the current
step is validated, if the current step is valid, next tab’s contents
are loaded with ajax. Validations are not executed when flow goes
back.
I think it can be done, if I can call primeface validation manually. Then below code will do the job:
<p:wizard showNavBar="false" widgetVar="wiz">
...
</p:wizard>
<h:outputLink value="#" onclick="PF('wiz').checkClientValidation();">Next</h:outputLink>
<h:outputLink value="#" onclick="PF('wiz').checkClientValidation();">Back</h:outputLink>
Any comments? Can I call client validation manually? Do you think above is good solution!
You can use a commandButton instead of outputLink and set the validateClient=true attribute.
Validations happen in the ValidationsPhase, so its partially client side only.
You don't need to trigger validation manually on the client side.
Is there any reason you have to use the outputLink ?
If you want to check the status of validations on the client side then you can use :
Example :
oncomplete="if (!args.validationFailed){PF('dialogId').show(); }"

how to implement progress bar for function in service and controller to show the status in grails platform

I am working on grails. I have a controller it calls service to check the value and one more call to do some calculation, by the time i want user to know its processing the function. Since i am new to grails , i dont know how to implement this in my project. I tried few plugins but i didnt know how to approach this by using plugin(Step by step). I need easiest way to solve this problem even this my ajax or javascript. i searched online i didnt get one.
Please help me to solve this .
Thank you.
Grails by default allows you to call controller methods with Ajax by default, you simply need to use the remoteFunction tag (http://grails.org/doc/2.2.1/ref/Tags/remoteFunction.html).
You use this by specifying an element on your page which will be updated by the html that you controller function returns, usually a gsp template.
For example, you could have your controller call the service to check for progress, and then the controller passes this returned progress amount to your gsp template. You use this value to draw a percentage, and return that html to your original page (this is whatever the controller returns - the remoteFunction tag handles the updating for you).
I suggest having a look for some examples of the remoteFunction call and going from there.
Hope that helps.

How to implement a navigation button in JSF 2.0 that doesnt do any validations of anything on the current page?

I want to implement a navigation button that takes the user to another page. I have no desire or need for any validations to run nor for the model to be updated, etc. I have implemented this as an ajaxified client-side redirect (note, I am using Primefaces 3.2).
It works-- but is this the best way to do this?
Navigating from the "onePage.xhtml" to the "anotherPage.xhtml"
onePage.xhtml:
...
<p:commandButton value="Navigate to Another Page"
process="#this"/>
action="anotherPage?faces-redirect=true"
...
Note, I have tried using immediate="true", however Apply Request Values phase still runs, which results in a NPE for me in a getter in my managed bean (as I no longer have the data that my getter needs).
Just use <h:button> or <p:button>. It sends a normal GET request. There's really no need for a POST-Redirect-GET request if it's just page-to-page navigation.
<h:button value="Navigate to Another Page" outcome="anotherPage" />
For the PrimeFaces look'n'feel, just replace h: by p:. Note that this component doesn't require a <h:form>. The link equivalent is the <h:link> (for which there's no PrimeFaces equivalent, there's anyway nothing which needs to be restyled).
See also:
When should I use h:outputLink instead of h:commandLink?
Set attribute immediate to true on commandButton, this will skip all validations, conversions or updates. Attributes causes JSF lifecycle to jump from Apply request values phase directly to Render Response phase.

Grails: Updating multiple page elements with ajax

It seems that with g:formRemote and g:submitToRemote, I can only specify one update target div. What would be a viable strategy for updating multiple divs?
if you want to stick with using the g:formRemote tags to perform your ajax, it might not be possible. Why not write some jQuery, and roll a custom ajax update? it couldnt be easier!
You could instead of using update, use onSuccess and parse the response and update the elements you need to update like this:
<g:formRemote name='loginForm' url="[action:'login']"
onSuccess='loginOK(e)' >
<!-- form fields -->
</g:formRemote>
<g:javascript>
function loginOK( resp ) {
// parse the resp.responseText and update
}
</g:javascript>
Or you could just use jQuery and roll your own like the previous answer suggests.
If you want to update one element based on success vs another on failure you can use a map like this:
<g:formRemote name='loginForm' url="[action:'login']" update="[success:'message',failure:'error']">
there is asolution to this grails problem, you can use taconite, where taconite allows to update muliple elements with one single ajax call
http://malsup.com/jquery/taconite/
and there is another solution posted at someone's blog, but my reputation does only allow me to post one link here on stackoverflow!!!
so i give the title of the blog post "Updating multiple page elements with Grails and Ajax"
From the grails doc for g:formremote, http://grails.org/doc/2.2.0/ref/Tags/formRemote.html , you can use the onSuccess callback to define a js function for a succesfull submit, so you can update all your target elements within that function, otherwise making an ajax call yourself also is a good option.

Creating an Ajax.ActionLink using javascript

I have a Todo List (an ASP.MVC UserControl) that for each row has the name of the task (that can be clicked to toggle between done/outstanding) and a delete button for removing the task - Both are created using Ajax.ActionLink to query the server.
When creating a new row I need the task text and delete button to be ActionLinks, how would I do this from the client side? Is there an Ajax.ActionLink equivalent in the Microsoft Ajax JS libraries?
Take a look at the code that is being generated using View Source. All you need to do is add the same markup and add the correct click handler via javascript. You may find it actually easier to do this with jQuery for all elements and add the jQuery code in your UserControl. At least that way you control the code and if Microsoft decides to change the way their ActionLink works, you won't get caught short.

Resources