-
1. Re: modify seam component from javascript
idyoshin Jan 6, 2010 3:33 AM (in response to steeve89)read documentation on Remoting :) there is a great info on doing this.
Best regards,
Ilya Dyoshin -
2. Re: modify seam component from javascript
tmalatinszki Jan 6, 2010 5:24 PM (in response to steeve89)Hi István,
You can find a cool tutorial about remoting here. First You need to set up remoting in components.xml, then You need to put @WebRemote annotation on setLat and setLng functions, and then:
<script type="text/javascript"> function updateVariables() { //Your previous code Seam.Component.getInstance("site").setLat(la); Seam.Component.getInstance("site").setLng(ln); } </script>
Regards,
Tamás
-
3. Re: modify seam component from javascript
tmalatinszki Jan 6, 2010 6:18 PM (in response to steeve89)Some details more: put these lines into components.xml:
<components xmlns:remoting="http://jboss.com/products/seam/remoting" xsi:schemaLocation="http://jboss.com/products/seam/remoting http://jboss.com/products/seam/remoting-2.1.xsd"> <remoting:remoting debug="true"/>
Then modify the bean this way:
import org.jboss.seam.annotations.remoting.WebRemote; @Entity @Scope(ScopeType.SESSION) @Name("site") public class Site { ... private double lat; private double lng; @WebRemote public void setLat(double lat){ this.lat=lat; } @WebRemote public void setLng(double lng){ this.lng=lng; } }
And in the xhtml:
<s:remote include="site"/> <script type="text/javascript"> function get(latlng){ map.panTo(marker.getPoint()); var la = latlng.lat(); var ln = latlng.lng(); Seam.Component.getInstance("site").setLat(la); Seam.Component.getInstance("site").setLng(ln); alert("Lat: " + la + ", Lng: " + ln); } </script>
Regards,
Tamas
-
4. Re: modify seam component from javascript
steeve89 Jan 6, 2010 6:19 PM (in response to steeve89)Hi Tamás!
I tried this way, before I opened this post. I saw this tutorial that is similar the seam reference tutorial. I tried to make the HelloWorld remoting example, but it didn't work. I've got a WARN message when I starting my JBoss server:
[JAXWSDeployerHookPreJSE] Cannot load servlet class: org.jboss.seam.remoting.SeamRemotingServletWhen I imported the jboss-seam-remoting.jar to my projekt, and I edited in Eclipse the web.xml, I've not find the SeamRemotingServlet class.
<servlet> <servlet-name>Seam Remoting</servlet-name> <servlet-class>org.jboss.seam.remoting.SeamRemotingServlet</servlet-class> </servlet>
I tried to find a jboss-seam-remoting.jar with this class, but I've not find. Do you think this is the source of trouble?
-
5. Re: modify seam component from javascript
tmalatinszki Jan 6, 2010 6:52 PM (in response to steeve89)Hmm...sounds weird, because my example is working fine in my test project without this servlet definition. My web.xml looks like this:
... <listener> <listener-class>org.jboss.seam.servlet.SeamListener</listener-class> </listener> <filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>Seam Resource Servlet</servlet-name> <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Seam Resource Servlet</servlet-name> <url-pattern>/seam/resource/*</url-pattern> </servlet-mapping> ...
As far as I know Seam Resource Servlet should be enough for remoting, so You should try again with this configuration (see this topic, they had a similar issue with Seam Remoting).
Please let me know if it is working fine this way.
Regards,
Tamás
-
6. Re: modify seam component from javascript
steeve89 Jan 6, 2010 8:36 PM (in response to steeve89)Hi Tamás!
Unfortunately, this isn't works in my case. I'd like to talk with you in Hungarian. If you registered in facebook, I found 1 result of your name, but I don't sure whehter you're (you play guitar in this picture).
Please write here if you're.
-
7. Re: modify seam component from javascript
tmalatinszki Jan 6, 2010 9:18 PM (in response to steeve89)You're right, that's me. :)
Just drop a message on me, but after we find the root cause of this issue don't forget to post that here.