cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a JSF Bean setter via AJAX

alr
Champ in-the-making
Champ in-the-making
Hi

If I got it right, it is right now only possible to call a getter of a JSF Bean with the help of the ajax servlet as mentioned in http://wiki.alfresco.com/wiki/AJAX_Support. Is it also possible to create POST request where I call a certain setter with an argument?

After reading the AjaxServlet class source, there is already applied a set parameter to the "Command" Enumeration, but it is not used in any way in the service method. Implementing it would be quite quick, however I do not intend to patch the AjaxServlet - if possible.

I just checked out  the HEAD and there still seems no support for a SetCommand. Does anyone know a way, I could extend the AjaxServlet as unobtrusive as possible? Hints and pointers to the right direction are as always appreciated.


–Alexander
1 REPLY 1

alr
Champ in-the-making
Champ in-the-making
Hi,

me again, giving a short status update. I think I got it now, why there is not a SetCommand implemented yet. I upgraded the AjaxServlet and added a SetCommand very similar to the GetCommand call.

Now this is the problem, best done as a use-case, so you know, what I want to do:

1. Login as usual
2. http://localhost:8080/alfresco/ajax/set/DetailBean.addTag?tag=WEBTAG
3. http://localhost:8080/alfresco/ajax/invoke/DetailBean.saveTag
4. http://localhost:8080/alfresco/ajax/get/EditMediaDetailBean.tags


This should be quite a clear example. First we login, then we add a set and call DetailBean.setTag("WEBTAG") and third we call saveTag() in the bean. Last but not least we use the getTags method to check our results.

The problem with all of the calls is, that I get a different FacesContext for each of these calls, leaving me with no changes whatsoever. There are two possible workarounds to this problem:

1. Put a persistence logic in every setter
2. Get back the right FacesContext

Of course I would love to stick with solution number, but I am not really sure whether this is possible.


Thanks for help and have a nice day