0 Replies Latest reply on Aug 23, 2007 11:11 AM by Fredrik Forsberg

    execute action and remote method simultaneously?

    Fredrik Forsberg Newbie


      I use Seam 2.0.0 BETA1 with facelets (Sun JSF 1.2 RI)

      I am having problem executing a WebRemote method and an action method from the same commandButton.

      On the frontend I have an xhtml page with an editor (FCKeditor) combined with a form bound to a seam datamodel component. The remote method on the seam component shall recieve the content of the editor (because it cannot have a jsf value binding) and the action shall recieve the datamodel.

      The seam component looks like this:

      public class ArtistPresentationActionBean extends ArtistPresentationActionBase
       implements ArtistPresentationActionLocal,
       ArtistPresentationActionRemote {
       public java.lang.String handleUpdateArtistPresentation() throws FactDaoException,
       ContentProviderAccountDaoException {
       // implementation
       protected void handleSetDescription(String description) throws Exception {
       // implementation. Annotated with @WebRemote on the local interface

      The commandButton on the form looks like this:

      <h:commandButton type="submit" onClick="setDescriptionAsync()" value="Save changes" action="#{artistpresentation.updateArtistPresentation}" />

      The javascript function setDescriptionAsync looks like this:

      function setDescriptionAsynch() {
       oEditor = FCKeditorAPI.GetInstance('MyTextarea');
       editorContent = oEditor.GetHTML();

      The problem is that only the remote method is executed, not the action. And when the remote call is finished executing I get a javascript exception in the browser saying that in remote.js at line 644 there is some problem with

      if (req.status == 200)

      and from there I am not sure what is wrong. Must be something with the response from the call. There are no exceptions thrown from the seam component after remote execution (not what I can see in the log, except of course in the browser).

      If I remove the onClick attribute on the commandButton the action is executed as expected without any failures.

      I reed in a book; Jboss Seam Simplicity and Power Beyond Java EE chap. 17.3.2 that it should work to execute both actions and remote methods in the same commandButton.

      Anyone experiencing the same thing?