Finally I solved all my problems ;-)

Thinks to take into account:

1) Return null should work (see the thread) --> For me it wasn't working due to a side-effect problem. If it doesn't then use an array to define buttons that must be ajaxed (see thread)
2) VERY IMPORTANT --> Define the AAFilter as being the first filter in your chain --> This was the cause of all my problems with NULL pointer exception --> At least it MUST be the first one when another ServletResponse wrapper is in the game (as was happening with the ExtensionsFilter response wrapper)
3) If you're using Firefox, download the script debugger to see what's happening with JS behind the scenes ;-) You will find lots of interesting stuff, like preprocessors to the Ajax request, for example ;-)
4) Don't use redirect in the navigation rules, or the Ajax request will be simply bypassed

Hope it helps to clarify the use of Ajaxanywhere with Myfaces.

Thanks to anyone that has given me any kind of support with this issue, and thanks very much to guys like Vitaliy for giving us tools like this fantastic Ajaxanywhere :-)

2006/2/23, Enrique Medina <[EMAIL PROTECTED]>:
Sorry, you were right...

I've tried it and it works great, but there are some cases where I get a NullPointerException when clicking the ajaxed button. But then I click it again, and it works!!! Debugging through your code, I see that when the cause why the exception is thrown is due to a call to the internal writer object of your BufferedResponseWrapper class, which is null. But it is not null for the second request on the same button... I'm missing something...

By the way, using your proposal, should I continue using the ajaxAnywhere.getZonesToReload?

Thanks very much for your support ;-)

2006/2/23, Vitaliy Shevchuk < [EMAIL PROTECTED]>:
it IS the other way round ;) read carefuly my message
 
ajaxAnywhere.substituteSubmitButtonsBehavior(true,[ajaxAnywhere.findForm().elements['mainForm:selectBoxBtn']]); // <-- arrays of "ajaxed" buttons
----- Original Message -----
Sent: Thursday, February 23, 2006 8:38 AM
Subject: Re: Ajaxanywhere

Hi Vitaliy,

Then you mean that buttons that are not Ajaxed must be passed as argument to the substituteSubmitButtonsBehaviour? I though it was the other way round; i.e. arrays of "ajaxed" buttons...

2006/2/22, Vitaliy Shevchuk <[EMAIL PROTECTED]>:
Hi guys,
 
first of all, sorry for not providing a proper support on AjaxAnywhere forum. I have been doing it for over 4 months but don't have much of free time now.
 
The first solution for your problem is to specify a list of Ajaxed buttons when calling substituteSubmitButtonsBehavior. So other buttons would stay
For "all2.jsf" from the DEMO application it would look like this :
    ajaxAnywhere.substituteSubmitButtonsBehavior(true,[ajaxAnywhere.findForm().elements['mainForm:selectBoxBtn']]);
then, if you add a second command button
    <h:commandButton action="" value="Calc No AJAX" id="selectBoxBtn_nonAJAX" />
it would work without Ajax.
 
 
Vitaliy.
 
PS. Indeed, there are several bugs discovered here and I need to fix them. It should work when returning null from getZonesToRefresh(), next release will fix it.
PPS. for the navigation to another page when submitting with AA, did you try "redirect" parameter in JSF config? I'm not sure but it should work, as response.sendRedirect() is interpreted as location.href="" on the client side.
----- Original Message -----
Sent: Tuesday, February 21, 2006 9:45 PM
Subject: Re: Ajaxanywhere

And more testing...

I have downloaded the DEMO from the Ajaxanywhere site, and made a change on the facesFrame.jsp to make the "Calculate price" button non-ajaxed. And it does not work; i.e. if I quit the "Calculate price" from the ajaxed zones, then the action is never executed.

From my experience, Ajaxanywhere does not work with a page combining ajaxed and non-ajaxed JSF actions.

2006/2/21, Enrique Medina <[EMAIL PROTECTED] >:
Definetively, I can't make it work. I've created a simple JSF page with two buttons: one is a save for the form and the other just navigates to another page (simulating a cancel action). The save button works great, but when I press the cancel/exit button, then nothing happens.

I've been also doing some debugging, and when using Ajaxanywhere, the submit of the non-ajaxed button does not update the parameterRequestMap used after to decide whether it is an immediate request, etc.

No idea of what I'm doing wrong....

Emmanuel can you please help? Can you provide some of your JSF pages? What version are you using? Are you working with buttons?

Thanks.


2006/2/21, Enrique Medina < [EMAIL PROTECTED]>:
Some more testing...

If I remove all the JS I posted before, then the common JSF button works, and obviously my ajaxed zone is ignored and the page is completely refresehd; if I add it again, then the common JSF does not work, and obviously the ajxed zone works great.

It's clear the problem comes with the JS and how does Ajaxanywhere handle the request...

2006/2/21, Enrique Medina < [EMAIL PROTECTED] >:
Hi again,

I have tried the solution you proposed about returning null for non-ajaxed requests, but I can't get it to work :-(

Here is my JS code:

ajaxAnywhere.getZonesToReload = function(url, submitButton)
                {
                    if (typeof submitButton != 'undefined')
                    {
                        if (submitButton.type == 'submit')
                        {
                            if ( submitButton.id.search('botonAjax') != -1)
                            {
                                return 'variablesSalidaList';
                            }
                        }
                    }
                   
                    return null;
                }

                ajaxAnywhere.formName = 'bodySubview:mainForm';
                ajaxAnywhere.substituteFormSubmitFunction ();
                ajaxAnywhere.substituteSubmitButtonsBehavior(true);

As you can see, I evaluate the ID of the submitButton to be something like *botonAjax*, so I can differentiate from the other buttons. And in any other case, I always return null. But when I press a button out of the ajaxed zone, it simply does nothing (well, the request is made, and the page is refreshed, but no navigation to the new page).

Any ideas of what could I be doing wrong? I'm convinced that maybe my problem has something to be with the JS code... or maybe not...


2006/2/21, Emmanuel Jay < [EMAIL PROTECTED]>:
Yes our app has ajaxed and non ajaxed part. For example some parts can't be ajaxed at all, such as the part using the fileUpload component (as well as any get operation for that matter).

Yes i use the link id to determine whether it is an Ajax request or not. Basically for a link it is:

var linkFrom = this.findForm().elements["mainForm:_link_hidden_"].value;

P.S. I have my own problem with AA, seems that the dataScroller doesn't work well with AA (if you ever come accross that case I'll be glad to hear if you manage to solve it!)


On 2/21/06, Enrique Medina < [EMAIL PROTECTED]> wrote:
Umm, I see. So your application has JSF pages with parts "ajaxed" and other parts, as usual JSF requests, don't you? I'll try it and let you know whether it finally works or not.

By the way, just for the sake of confirmation, is your JS code similar to mine? I mean, do you use the button or link ID to determine whether it's an "ajaxed" request or not?

Thanks very much for your support.


2006/2/21, Emmanuel Jay < [EMAIL PROTECTED]>:
I think the AA filter is totally by passed if the list of zones to reload is null (getZonesToReload returns null). In our app we mostly have links and returning null works fine.



On 2/21/06, Enrique Medina < [EMAIL PROTECTED]> wrote:
Null? I remember some tests returning '' and getting a NullPointerException. What should be the reason why returning NULL should work?

2006/2/21, Emmanuel Jay < [EMAIL PROTECTED]>:
Hi Enrique,

If you want you button or link action not to go through AA you have to return null for those in  getZonesToReload.

Hope that helps,

Emmanuel


On 2/21/06, Enrique Medina < [EMAIL PROTECTED]> wrote:
Hi,

Has anyone successfully used Ajaxanywhere inside a JSF page with a piece of the page being "ajaxed" and the other piece not? Let me give an example: imagine a JSF page where the selection of a combo box must force the refresh of another combo box. This zone is "ajaxed" using <aa:zoneJSF>. But buttons to save or go to another page in the navigation are not "ajaxed".

My problem is that the "ajaxed" zone works great, but then I have a button to save, and another one to navigate to another page, and those buttons don't seem to work. When I click them a request is sended, but none of their respective actions are executed, no error messages are shown (I have a global tag in the page). It seems like a request with an action returning simply null (not doing anything).

My _javascript_ for Ajaxanywhere looks like this:

ajaxAnywhere.getZonesToReload = function(url,submitButton)
{
    if (submitButton.id.equals('myAjaxButton')
        return "dataZone"; 

 
ajaxAnywhere.formName = "mainForm"; 
ajaxAnywhere.substituteFormSubmitFunction(); 
ajaxAnywhere.substituteSubmitButtonsBehavior(true); 

What am I doing wrong? How do you have to indicate non-ajaxed buttons in the getZonesToReload _javascript_ callback?












Reply via email to