Hi

I think we need to give this a good hard thought. What you (if I read you
right) are saying in essence is that Shale/Clay and Ajax will not work.

That is a scenario that we can not have - This needs to be addressed,
otherwise we will loose out before we even begin.

The scenario that I outlined, is something that we need to support in these
web 2.0(3.0?) days because fullpage rendering of dynamic content is not
acceptable anymore - hence the efforts of PPR in for instance in Trinidad
and also other opensource projects. If PPR of Dynamic MyFaces stuff can be
achieved than it should also be doable in Shale/Clay

So lets put our heads on the block :)

Hermod



-----Opprinnelig melding-----
Fra: Gary VanMatre [mailto:[EMAIL PROTECTED] 
Sendt: 6. desember 2006 18:54
Til: user@shale.apache.org
Emne: RE: CLAY: Using clay to import file in remoting method

>From: <[EMAIL PROTECTED]> 
>
> 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. 
>

This would be really interesting but there are several challenges.  I've
been looking at the myfaces Trinidad components.  The provide a parital page
rendering strategy that is a different from Shale's remoting. 

Shale's remoting is build for invoking logic in a backing bean and
delivering a XML response.  It doesn't try to use the component tree that
rendered the original page.

The Trinidad component library for PPR uses the component tree and hooks
into the entire lifecycle.  A partial page request results in the current
page's component tree getting restored.  The PPR is applied to the entire
component tree but the results are filtered.

This makes a lot of sense.  The page can be treated a whole using a browser
submit or individual components within the page.  It is important that the
entire page is represented by the component tree.

However, dynamically changing the tree from an action callback is different
than working with a static tree.  You could potentially be removing a
component from the tree that invoked an action that is removing itself.
There are also timming issues when the component tree is saved within the
lifecycle. Normally the view state is saved after rendering.  In JSF 1.1
this is done from the ViewTag.  Clay invoke the this logic from the view
handler when using full template views.

Outside of PPR, if we are going to try to change the component tree in the
invoke application phase, we would need to find the clay component, clear
it's children, assign a new jsfid (template).  We would need to tell the
state manager to save state on the tree because the next phase would be to
render the response.  If we are using a actionListener without an action
outcome, the modifed tree would be rendered.  However, if we have an action
outcome that matches a navigation rule, the view will be recreated and our
work is lost since the view will be rebuild for the original template.

If we are going to try to use Shale's remoting, we would need to some how
restore the view by passing on the viewId in our remoting request, find the
Clay component in the tree, remove the children, set a new jsfid, invoke
rendering using a dummy response writter, save the component tree and return
the rendered markup.  This only really addresses rendering.  We would also
need to simulate decoding the values delivered from the parital page
request.  The renderering can be decoupled from the the tree but decoding
the submitted values needs a UIViewRoot at the top to store queue events.

I have an experment in the sandbox of using Trinidad PPR with attached
script to add dynamic content.  It only handles rendering and wouldn't be
usefull for anything other than devlivering static content.

Maybe you can use some ideas for here:
http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java
/org/apache/myfaces/trinidad/blank/CatalogBacking.java?view=markup



> Hermod 
> 

Gary

> -----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" 
> > > 
> > > 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? 
&a mp;g t; 
> 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 sni ppet. 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 t he r esponse 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 
> &g t; 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 
> L ist extraDetails = getExtraDetail(id); 
> 
> /** This works, but HTML is hard-coded into the 
> ViewController... 
> String html = "
" 
> for( String detail: extraDetails ) { 
> html += " " + detail + "
"; 
> } 
> html += "
"; 
> 
> // 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