Hi

I think that this can be very useful in conjunction with PPR. In this way one 
could define an outcome that was just a Clay component, where the component was 
not a complete page, but a pagefraction. It would then be very easy to use Ajax 
to put that into the div's innerhtml because it would(should) be a complete 
component body. There might be implications regarding state that I don't see 
though.

Hermod

-----Original Message-----
From: Ian.Priest [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 05, 2006 11:22 AM
To: user@shale.apache.org
Subject: RE: CLAY: Using clay to import file in remoting method


 
Responses below... 

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: 04 December 2006 15:54
> To: user@shale.apache.org
> Subject: Re: CLAY: Using clay to import file in remoting method
> 
> >From: "Ian.Priest" <[EMAIL PROTECTED]>
> >
> > Hi,
> > 
> > I've set up a couple of remoting methods, but I don't 
> really want to 
> > code the HTML in my java method.
> 
> Are you talking about Shale/Ajax style of remoting?

Yup.

> 
> >What I'd like to do is have the snippet  of HTML returned by my 
> >remoting method defined in the same way as the  rest of the 
> html on the 
> >site; i.e. in an html file that's loaded by  Clay.
> > 
> 
> Do you want to pull this html content from a place other than 
> the classpath or the web context root?

>From within the web-context root. In fact it would live side-by-side
with the main page. So if I had page main.html and wanted to return
snippet.html as the response to the remoting call then I'd arrange it as

/somedir/main.html
/somedir/snippet.html

> Is the html dynamic or static?
> 

The content of snippet.html would be dynamic. In my use case I go and
get a List of extra info about an item and would want snippet.html to
render a table with a row per List entry.

> 
> > My remoting method fetches a detail list when a table row 
> is clicked, 
> > a little like opening the next level of a tree, so what I'd 
> like to do is:
> > 
> > 1. User clicks on row x in the table
> > 2. Remoting method viewController.getDetails() is called 3. 
> > viewController.getDetails() loads details of x as a List and sets a 
> > variable theList 4. viewController.getDetails() creates an 
> instance of 
> > Clay that loads file theDetails.html 5. File 
> theDetails.html renders 
> > as a couple of table rows using
> > viewController.getTheList() to get table contents 6. 
> > viewController.getDetails() gets the HTML rendered by the Clay load 
> > and writes it out as the response to the remoting method
> > 
> 
> Are you trying to render a static document or do you need to 
> collect and store data?
Not static. I collect then want to display more data. My remoting method
gets more information then renders a dynamic document to return as the
response from the remoting method. The dynamic document displays the
extra info.

> 
> Or, are you looking at the Clay runtime options using the 
> shapeValidator callback and you would like to load html fragments?
>
Yes, I'm trying to understand how (or if) I could use class
org.apache.shale.clay.component.Clay to process a subtree and then grab
the HTML result of that processing to return as the output of my
remoting method.

> 
> > Doing the above means the HTML style agency will still be 
> able to edit 
> > the HTML look and feel without me having to edit the Java 
> code for them. 
> 
> What part of the java code are you talking about?

The remoting method. It generates HTML and uses a ResponseWriter to
output the HTML to the page that made the remoting call. I would like to
generate that HTML by calling Clay and having it render a sub-tree, but
I can't see how to do it or even if it can be done. Pseudo-code...

Class MyViewController extends AbstractViewController {

        /**
        * Called by AJAX function in page main.html
        *
        * Use Clay to render a dynamic snippet of HTML then return it.
        */
        public void aRemotingMethod() {
                // Get item id
                String id =
getFacesContext().getExternalContext().getRequestMap().get("id");

                // Get more detail about item with id
                List<String> extraDetails = getExtraDetail(id);

                /** This works, but HTML is hard-coded into the
ViewController...
                String html = "<table>"
                for( String detail: extraDetails ) {
                        html += "<tr><td>" + detail + "</td></tr>";
                }
                html += "</table>";
        
                // Can I somehow use Clay here to generate HTML?
                // Clay clay = new Clay();
                // Need to set URL of snippet.html as view id
                // Need to make extraDetail available to the processor.
Make this class
                // the ViewController for snippet.html?
                // Get clay to process: clay.encodeBegin()?
                // Get HTML back from clay somehow once sub-tree is
created
                // String html = clay.?????()

                // Return HTML
                writer.write(html);
                getFacesContext.responseComplete();

        }
}

> 
> > I want to avoid reloading the page or sending a full tree 
> view that can 
> > just be unfolded as the page size would then be potentially 
> very large. 
> > 
> > Is this possible? Are there any code examples? 
> > 
> 
> I'm not sure that I understand your use case but it sounds 
> like you want the html content fragments to be managed 
> outside of the web application?

I want the HTML fragment to be managed outside the ViewController class
code, yes. The third parties can edit snippet.html to alter the
look-and-feel.

> 
> 
> > Cheers, 
> > Ian. 
> > 
> 
> Gary
> 
> 
> > 
> > 
> 



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Reply via email to