This is my lzx file and the java class - with the HashMap example I actually get 2 rows in the datagrid, however no data shows up.
I initially had the return of String test() as the dataset

Ruben

// sample trying to return an XML string
   public String test() {
       return "<quotes>"+
"<quote id=\"200\" text=\"quote 10\" firstname=\"Ruben\" lastname=\"Reusser\" plan=\"1500\" type=\"Self\" date=\"1/1/2007\"/>"+ "<quote id=\"199\" text=\"quote 1\" firstname=\"Carla\" lastname=\"Poulin\" plan=\"1500\" type=\"Family\" date=\"1/2/2007\"/>"+
       "</quotes>";
   }
public static Hashtable getProperties()
   {
           return System.getProperties();
   }


// sample trying to return a HashMap
   public HashMap test()
   {
       HashMap map = new HashMap();
       map.put("id", "200");
       map.put("text", "quote 10");
       map.put("firstname", "Ruben");
       map.put("lastname", "Reusser");
       map.put("plan", "1500");
       map.put("type", "Self");
       map.put("date", "1/1/1907");

       HashMap quoteMap = new HashMap();
       quoteMap.put("quote1", map);

       map.put("id", "201");
       map.put("text", "quote 10");
       map.put("firstname", "Ruben");
       map.put("lastname", "Reusser");
       map.put("plan", "1500");
       map.put("type", "Self");
       map.put("date", "1/1/1907");
       quoteMap.put("quote2", map);

       HashMap returnMap = new HashMap();
       returnMap.put("quotes", quoteMap);
return returnMap;
   }


<canvas width="800" height="600">
   <dataset name="quoteData"/>
<security>
       <allow>
           <pattern>^examples\.ConstructExample</pattern>
       </allow>
   </security>

   <!-- See $LPS_HOME/WEB-INF/classes/ConstructExample.java for java
       source. -->
   <javarpc name="ce" scope="session" autoload="true"
            remoteclassname="examples.ConstructExample">

       <handler name="onerror" args="err">
           Debug.write("----------");
           Debug.write("onerror:", err)
       </handler>

       <handler name="onload">
           Debug.write("----------");
           Debug.write("constructed with", this.createargs);
           Debug.write(this.proxy);
       </handler>

       <remotecall name="test" funcname="test" dataobject="quoteData">
<handler name="ondata" args="value">
               Debug.write('result is:');
               Debug.inspect(value);
               Debug.inspect(quoteData);
       </handler>
</remotecall> </javarpc>

   <button x="10" y="10" onclick="ce.test.invoke();">
   </button>

<grid x="10" y="40" bgcolor="0xffffff" datapath="quoteData:/*" width="400" height="400">

<gridtext editable="false" datapath="@date"> Date </gridtext>
               <gridtext editable="false" datapath="@id"> ID </gridtext>
<gridtext editable="false" datapath="@firstname"> First Name </gridtext> <gridtext editable="false" datapath="@lastname"> Last Name </gridtext> <gridtext editable="false" datapath="@plan"> Plan </gridtext> <gridtext editable="false" datapath="@type"> Rated for </gridtext>

   </grid>

</canvas>




Henry Minsky wrote:
Can you send a small example of what your code looks like ?
There is an example in the source distribution in test/rpc/javarpc/serverenv.lzx, which accesses a server side call to system environment info test.xmlrpc.SystemProp

<canvas debug="true" width="800" >

<!--    <debug x="370" width="400" height="300" /> -->

    <alert name="errormsg"/>

    <simplelayout spacing="10"/>

    <dataset name="envDset" />

    <list name="env" width="250" height="200">
<textlistitem name="ti" datapath="envDset:/*" text="$path{'name()'}">
            <method event="onselect">
                canvas.display.setText(datapath.xpathQuery('text()'))
            </method>
        </textlistitem>
    </list>
<text name="display" selectable="true" width="350" multiline="true" bgcolor="0xd0d0d0" />

    <security>
        <allow>
            <pattern>^org\.openlaszlo\.test\.xmlrpc\.SystemProp$</pattern>
        </allow>
    </security>

    <javarpc name="systemprop" scope="none"
             remoteclassname=" org.openlaszlo.test.xmlrpc.SystemProp">

        <method event="onload">
            Debug.write('onload invoke');
            this.getProperties.invoke();
        </method>

        <method event="onerror" args="msg">
            errormsg.setAttribute('text', 'error: ' + msg)
            errormsg.open()
        </method>

        <remotecall name="getProperties" funcname="getProperties"
                    dataobject="$once{envDset}">
            <method event="ondata" args="d">
                Debug.write('data:', d);
            </method>
        </remotecall>

    </javarpc>



Java Code:

package org.openlaszlo.test.xmlrpc;

import org.apache.xmlrpc.*;
import java.util.*;

public class SystemProp
{
        public static Hashtable getProperties()
        {
                return System.getProperties();
        }

    public static void main(String argv[])
    {
        WebServer ws = new WebServer(8181);
        SystemProp se = new SystemProp();
        ws.addHandler("localservice", se);
        ws.start();
    }
}


On 7/19/07, *Ruben Reusser* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    hi

    I am new thew openlaszlo and figured I do a little test program using
    JavaRPC and the 4.0.2 release. I am trying to populate a dataset
    (list)
    from a value returned from my java class but seem to fail.
    I can call the java class and get a return value (String) that is an
    XML. However, I am not sure if that is the way I am supposed to do
    it or
    not. When I look at the dataset it's empty. Does anyone have an
    example
    program that does that?
    I checked the mailing list and the forum but I am unable to find a
    working example (I can find a couple of people asking the same
    question).

    Thanks

    Ruben




--
Henry Minsky
Software Architect
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>


Reply via email to