2 Replies Latest reply on Jul 23, 2007 9:52 AM by dkane

    Changing Seam component properties via Remoting

    dkane

      Hello

      I have a Java class that is responsible for some graphics in my web-application. I have turned this class into Seam component. Actually this is session-scoped graphic provider for a4j:mediaOutput element (image) . This works well.

      There is some plain JavaScript code on web-page that changes properties of this component. These changes are implemented via Seam Remoting.

      The problem is following : properties changed in backing stateful bean via Remoting does not change accordingly in the context instance of the component. I guess I need some explicit outjection back to context after Remoting call, but don't know how to program that. Otherwise, any consequent non-remoting invocation of the component turns backing bean into previous state .

      Thanks in advance for explanations.

        • 1. Re: Changing Seam component properties via Remoting
          shane.bryzak

          Seam's bijection features should work just the same within a remoting call as they do with a faces request. Can you please post some code showing what you're trying to do?

          • 2. Re: Changing Seam component properties via Remoting
            dkane

            There is a lot of code, so only key points :

            Seam Component interface :

            @Local
            public interface MapImageA4J
            {
             public void setXc(int xc);
             public int getXc();
             public void setYc(int yc);
             public int getYc();
             public void setWidth(int width);
             public int getWidth();
             public void setHeight(int height);
             public int getHeight();
             public void setScale(int scale);
             public int getScale();
             public void drawImage(OutputStream out, Object data) throws Exception;
            
             @WebRemote
             public void zoom(double xPercent, double yPercent, double widthPercent, double heightPercent);
            
             // this method is being called via Remoting and changes values of properties xc, yc, scale, etc.
            
            
             public void left();
             public void right();
             public void up();
             public void down();
             public void zoomIn();
             public void zoomOut();
             public void destroy();
            }
            



            Web - page fragment :

            
             <s:link action="#{map.left}" value="left"/><br/>
             <s:link action="#{map.right}" value="right"/><br/>
             <s:link action="#{map.up}" value="top"/><br/>
             <s:link action="#{map.down}" value="bottom"/><br/>
             <s:link action="#{map.zoomIn}" value="zoom in"/><br/>
             <s:link action="#{map.zoomOut}" value="zoom out"/><br/>
            
             <!-- links above works fine and image is being rerendered -->
            
             <a4j:mediaOutput id="a4map"
             element="img"
             cacheable="false"
             session="true"
             createContent="#{map.drawImage}"
             mimeType="image/gif"
             onmousedown="mapStartZoom(event)"
             onmousemove="mapMouseMove(event)"
             onmouseup="mapMouseUp(event)"
             />
            


            And, the problem point : end of "onmouseup" handler (Javascript):

            function mapStopZoom(evt)
            {
             //... some calculation ...
            
            Seam.Component.getInstance("map").zoom(xLeftPercent,yTopPercent,widthPercent,heightPercent);
            }
            


            zoom method is being called via Remoting, but when I click e.g. "up" or "down" after zoom results falls back.

            I've raised the similar issue in ajax4jsf forum, because I beleive the problem is impossibility to rerender mediaOutput right after remoting call.
            So far have not found a way to rerender a4j object from plain JavaScript.

            http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066643#4066643