On 10/13/11 15:19 , Niclas Hedhman wrote:
Promising. As I am just starting to architect a new app that needs a
strong formal ReST interface, I am particularly interested in this.

Question; In your example you have a query link without arguments. How
are those supposed to be provided? (Gosh I need to read up on this
again...)

That was the simplistic case where the query does not need any parameters. This example executes a query that requires a form to be filled in, and then executes a command after that:
crc.onResource( new ResultHandler<Resource>()
{
    @Override
public void handleResult( Resource result, ContextResourceClient client )
    {
        client.query( "querywithvalue", null );
    }
} ).onProcessingError( "querywithvalue", TestQuery.class, new ResultHandler<TestQuery>()
{
    @Override
public void handleResult( TestQuery result, ContextResourceClient client )
    {
ValueBuilder<TestQuery> builder = module.newValueBuilderWithPrototype( result );

builder.prototype().abc().set( "abc" + builder.prototype().abc().get() );

        client.query( "querywithvalue", builder.newInstance() );
    }
} ).onQuery( "querywithvalue", TestResult.class, new ResultHandler<TestResult>()
{
    @Override
public void handleResult( TestResult result, ContextResourceClient client )
    {
        client.command( "commandwithvalue", null );
    }
} ).onProcessingError( "commandwithvalue", Form.class, new ResultHandler<Form>()
{
    @Override
    public void handleResult( Form result, ContextResourceClient client )
    {
        result.set( "abc", "right" );

        client.command( "commandwithvalue", result );
    }
} );

crc.refresh();
---
The first handler will get the form for the query. Then the second one, on "processing error" (since the form was not filled in), will take the default form and update the values and send it again. On response from that it invokes a command, which fails as it did not send in a form, and then when it gets the form that is filled in and submitted.

That would be a more realistic sequence of things, and where each step can be repeated, depending on how the flow goes. Note that there is no URL building anywhere, just as you never modify URL's when you use a web browser. You click on links and submit forms.

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to