6 Replies Latest reply on Oct 27, 2010 4:20 AM by notify

    can i pass this array return by java script to my session bean

    sadiquekatihar

      any suggestion would be acceptable.


      I have a java script functions that return an array. I want to use this array on my session bean when page is submitted by user.


      how can i pass this array return by java script to my session bean's java method.

        • 1. Re: can i pass this array return by java script to my session bean
          notify

          You will need to use Remoting to call a method in a session from JavaScript.


          Where piNPOiNTsList is a two dimensional array.


          XHTML;


          <s:remote include="devicesToTrackBean" />
          
          .....
          
          piNPOiNTsList[j][5] = distance/1000;
          
          .....
          
          var devicesToTrackBean = Seam.Component.getInstance("devicesToTrackBean");
          devicesToTrackBean.setPiNPOiNTsDistances(piNPOiNTsList);
          



          EJB 3 Session Bean Interface;


          @WebRemote
          void setPiNPOiNTsDistances(String [][] piNPOiNTsListArray);
          



          EJB 3 Session Bean;


          public final void setPiNPOiNTsDistances(String [][] piNPOiNTsListArray) {
              .....
          }
          



          • 2. Re: can i pass this array return by java script to my session bean
            cosmo

            You could XMLize your array in javascript, then pass it as described here and finally deXMLize it in java.

            • 3. Re: can i pass this array return by java script to my session bean
              sadiquekatihar
              First of all thanks a lot for your help

              I have applied both the above approach in jboss-seam project to pass a array from java script to my session bean via xhtml.
              But i request you all please help me for this.

              1. I am new in seam technology so i have no more knowledge about <S:remote > . could you explain it more.

              2. I have also tried the second approach but it is working only with <input></input> but not with   <h:commandButton> or <ice:commandButton>.

              i want to sure about can i perform both the operation of reading and writing on a ice:face input text. if it is possible the how ?

              Please help me i am waiting for your reply.
              • 4. Re: can i pass this array return by java script to my session bean
                notify

                1. I am new in seam technology so i have no more knowledge about
                <s:remote>

                Could you explain it more.



                Your XHTML should have (some of) this at top;


                <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:s="http://jboss.com/products/seam/taglib"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:rich="http://richfaces.org/rich"
                    xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
                    xmlns:excel="http://jboss.com/products/seam/excel"
                    template="layout/template.xhtml">
                   
                    <f:view contentType="text/html"></f:view>
                    <ui:define name="body">
                
                    <h1>Heading</h1> 
                    <s:remote include="devicesToTrackBean" />
                
                    <h:form id="yourForm" >
                



                The s:remote is from the Seam Taglib.

                • 5. Re: can i pass this array return by java script to my session bean
                  sadiquekatihar

                  Dear Lee



                  Thank you so much


                  I have applied your suggestion in my seam application and now it is working fine.


                  Now could i share one more problem , when i try this example on richface application it works fine but when i tried it with iceface application it doesn't work. why it is happening i am trying to resolve this

                  could you help for this....


                  please

                  • 6. Re: can i pass this array return by java script to my session bean
                    notify

                    sadique arslan wrote on Oct 26, 2010 14:46:


                    when i try this example on richface application it works fine but when i tried it with iceface application it doesn't work. why it is happening i am trying to resolve this


                    I use RichFaces. I seem to remember when you install SEAM you have specify whether you're using RichFaces or IceFaces. Maybe you choose RichFaces?


                    Are there any error messages? What does the Server log say?


                    Roger