RE: Restlet client and setting the request header date

2009-12-31 Thread webpost
Anyone have an answer to this?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2433923


Restlet GWT RPC 2.0

2009-12-31 Thread webpost
I am currently trying to build an application using the 2.0 M6 version of 
Restlet.

Ideally, I would like to use the GWT edition to consume resources on a J2EE 
edition server. Both are running v2 M6.

The problem I can't seem to solve is that of the remote RPC mechanism, I get a 
null pointer exception when trying to call the service using the code attached.

I'm trying to follow the GWT example that was posted on ongwt, but in that 
sample the GWT and RPC are in the same servlet context, in the case of my app, 
I need the GWT app on one context and the Rest service in a separate context. 
Is this possible, is this why it's not working?

Also when I compile the GWT app I get these error messsages, but it still 
compiles.

  [ERROR] Errors in 
'jar:file:/home/kedaly/Libraries/restlet-gwt-2.0snapshot/lib/org.restlet.jar!/org/restlet/client/engine/io/TraceInputStream.java'
 [ERROR] Line 42: No source code is available for type 
java.io.FilterInputStream; did you forget to inherit a required module?
 [ERROR] Line 59: The method write(int) is undefined for the type 
PrintStream
 [ERROR] Line 71: The method write(byte[], int, int) is undefined for 
the type PrintStream
 [ERROR] Line 84: The method write(byte[], int, int) is undefined for 
the type PrintStream
  [ERROR] Errors in 
'jar:file:/home/kedaly/Libraries/restlet-gwt-2.0snapshot/lib/org.restlet.jar!/org/restlet/client/engine/io/TraceOutputStream.java'
 [ERROR] Line 55: The method flush() of type TraceOutputStream must 
override or implement a supertype method
 [ERROR] Line 56: The method flush() is undefined for the type 
FilterOutputStream
 [ERROR] Line 59: The method flush() is undefined for the type 
PrintStream
 [ERROR] Line 64: The method write(int) of type TraceOutputStream must 
override or implement a supertype method
 [ERROR] Line 65: The method write(int) is undefined for the type 
FilterOutputStream
 [ERROR] Line 68: The method write(int) is undefined for the type 
PrintStream/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.sqm.gwt.client.tabs.websitea;

import ca.sqm.api.data.TestCase;
import ca.sqm.gwt.client.images.ImageResources;
import ca.sqm.gwt.client.tabs.BaseAppTab;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.TextBox;
import org.restlet.client.data.MediaType;
import org.restlet.client.data.Preference;
import org.restlet.client.resource.Result;

/**
 *
 * @author kedaly
 */
public class Websitea extends BaseAppTab {

private final TestProxy testResource = GWT.create(TestProxy.class);
private Label lblServerReply = new Label();
private TextBox txtLastName = new TextBox();
private TextBox txtFirstName = new TextBox();
private TextBox txtAge = new TextBox();

private Button btnGet = new Button(Get From Server);
private Button btnSave = new Button(Save to Server);

public Websitea() {
super(Website Access);
setIcon(ImageResources.INSTANCE.websiteaccess16x16());
add(new Label(Input your text: ));
add(txtFirstName);
add(txtLastName);
add(txtAge);
add(btnGet);
add(btnSave);
add(lblServerReply);

//set up api path
testResource.getClientResource().setReference(/api/testapi);
testResource.getClientResource().getClientInfo().getAcceptedMediaTypes().add(new PreferenceMediaType(MediaType.APPLICATION_JAVA_OBJECT_GWT));


btnGet.addListener(Events.Select,new SelectionListenerButtonEvent() {

@Override
public void componentSelected(ButtonEvent ce) {
testResource.retrieve(new ResultTestCase() {

public void onFailure(Throwable caught) {
   Info.display(Error,What we have here is a failure to communicate +caught.getMessage());

   StringBuffer buf = new StringBuffer();
   
   for (StackTraceElement ele : caught.getStackTrace()) {
   buf.append(ele.toString());
   buf.append(br/);
   }

   lblServerReply.setText(buf.toString());
}

public void onSuccess(TestCase result) {
txtFirstName.setText(result.getFirstName());
txtLastName.setText(result.getLastName());
txtAge.setText(Integer.toString(result.getAge()));
}
});
}
 

RE: Restlet GWT RPC 2.0

2009-12-31 Thread Kevin Daly
To give some more insight on the problem. When I run the code in the debugger 
the code fails on line 229 of ClientAdapter.java. 

This line.

userCallback.handle(request, response);

I've looked at it in the debugger and there's no method to handle in the Proxy 
Class that I provided, the debugger also show that the class generated inherits 
from ClientResource, but I cannot find an implementation of handle(request, 
response) in ClientResource or UniformResource (parent class). 

This seems to be where the problem is occurring. Is this a bug, or am I doing 
something wrong?

By the way, Restlet looks excellent and I am looking forward to using it in 
2010. Happy New year to the Restlet Team.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2433998