Hi

Ok, that got a load of my shoulders.

Now, I obvously worded my intentions wrong here. What I am thinking of is the 
case that when an asynchronous request comes in there should be the possibility 
for Clay to render the response. I am not suggesting to alter the component 
tree as per se. I am aware that doing so would be dangerous, particularly in 
the case where the state is held on the client (Severside we could have full 
controll over the component tree). 

Lets assume that I have a table on my page, that I want to update using Ajax. 
Now there are two possibilities here. The first beeing just returning data that 
is then handled on the client side using a JSON type DOM altering. The other 
would be to just set the .innerHtml of the DOM component with a serverside 
rendered response. It's the latter scenario that I am thinking about and where 
using Clay to do the rendering.

Hemrod

-----Original Message-----
From: Gary VanMatre [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 06, 2006 10:45 PM
To: user@shale.apache.org; [EMAIL PROTECTED]
Subject: Re: SV: CLAY: Using clay to import file in remoting method


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

No, I'm *not* saying that Shale/Clay and Ajax will not work.  The testbed in the
sandbox is proof that it will work.  There are are a couple of pages that use
Trinidad's built in Ajax support and it works really well.  I'm using clay
templates with namespaces so they look pretty much like JSP.

http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/catalog.html?view=markup

All you have to do is nest the components you want partial rendering on 
in a panelPartialRoot component.

<tr:panelPartialRoot>
    <tr:commandLink actionListener="[EMAIL PROTECTED]" 
        partialSubmit="true" text="#{foo.name}"/>
</tr:panelPartialRoot>

These components know how to render the javascript required for PPR.  
This stuff is really a works of craftsmanship.  I've been told that this is 
their 
first generation of components.  The future stuff will blow you away 
with drag and drop and other sick client side effects.

However, I don't believe that these components will allow you to dynamically 
change the structure of a view without recreating it.  They don't have client 
side code adding widgets that are not already represented by some component 
in the backing view.  The client is not swapping out chunks of the view
tree using Ajax calls and then allowing the entire page to be posted back
as a whole.


> 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 Clay will need some help with is Ajax + dynamic 
views using Shale's remoting.

There are multiple scenarios for using remoting.  The Shale remoting is 
service centric versus component centric.


> 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 
> 

The challenge here is that this type of PPR is coupled with the components.  It
would be very difficult to create this type of generic snap-in remoting for 
components that were not build with this support in mind 
(the shale commons validator comes to mind).

Clay is a tool/utility for composing JSF views using something other than JSP.
It doesn't modify or add behaivor to the components it just snaps them 
together.


> So lets put our heads on the block :) 
> 

I wouldn't mind doing some work in this area but it would shift the focus 
of Shale more into component ware.


> Hermod 
> 

Gary

> 
> 
> -----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: 
> > 
> > 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