Re: Dynamic components with template (? extends BaseComponent)

2007-03-19 Thread Steve Shucker
If you've got the components you want somewhere else on a template, you 
can always use Block/RenderBlock.  That involves setting up @Block areas 
for each possible content and putting a @RenderBlock in the target 
area.  Then you just need a method to wire up the RenderBlock's block 
attribute.  Your target blocks can even be on another page.


I think the version of DynamicBlock you're pointing to is for tap3.  
I've got a bookmark to the t4 version, but the download links appear 
broken.  I'm not sure the author supports it any more.  I'm using it on 
tapestry 4.1.1 (with unrelated hacks to its source).

http://www.behindthesite.com/blog/C1931765677/E20060309215538/index.html

-Steve


Portuendo Vestado wrote:

Darn you're right, I've never even thought of that. finishLoad(), which I'm
overriding to add the new implicit component, is called only once before the
page gets cached. So basically, my dynamic component is only dynamic the
first time template loads.

The reason I chose this method is that if you do it (that is, attach a
component via addComponent()) at render time, say in pageBeginRender(), it
hits AbstractComponent.checkActiveLock() sentinel and throws a Component
Home is active and its configuration state may not be changed, which is
quite reasonable.

I guess I'm still on the lookout for an option to delegate rendering to a
component with a template. There must be a way of instantiating those just
as simple as pages (i.e. with IRequestCycle.getPage(...)).

Btw, DynamicBlock you mentioned, is this it:
http://www.behindthesite.com/blog/C1931765677/E1630021481/? Does it work for
4.1 - seems a little old, September 2, 2004.


Thanks,
-P

--

I don't know enough about tapestry internals to say if this is a good 
idea, but I've played around with DynamicBlock and your solution looks a 
lot simpler.  At a guess, it looks like your approach is setting up your 
dynamic component when tapestry is loading the page template.  If it's 
part of tapestry template cache, that means it would only pick the 
dynamic content the first time the page is loaded and reuse the same 
component on every subsequent call to the page - unless you're running 
in dev mode with page caching disabled.  But as I said, that's a guess.


If I'm wrong, I want to know how well does it handle things like 
RenderBody and passing parameters to your component?  If it handles 
those concerns well, I'm tempted to wrap it up into a generic 
DynamicComponent.


If I'm right, it probably jives with Howard's vision of static 
structure/dynamic behavior, but may not function in the way you intended.


-Steve






___ 
Yahoo! Mail - Sempre a melhor opção para você! 
Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic components with template (? extends BaseComponent)

2007-03-16 Thread Steve Shucker
I don't know enough about tapestry internals to say if this is a good 
idea, but I've played around with DynamicBlock and your solution looks a 
lot simpler.  At a guess, it looks like your approach is setting up your 
dynamic component when tapestry is loading the page template.  If it's 
part of tapestry template cache, that means it would only pick the 
dynamic content the first time the page is loaded and reuse the same 
component on every subsequent call to the page - unless you're running 
in dev mode with page caching disabled.  But as I said, that's a guess.


If I'm wrong, I want to know how well does it handle things like 
RenderBody and passing parameters to your component?  If it handles 
those concerns well, I'm tempted to wrap it up into a generic 
DynamicComponent.


If I'm right, it probably jives with Howard's vision of static 
structure/dynamic behavior, but may not function in the way you intended.


-Steve

Portuendo Vestado wrote:

Hi all,

I'm trying to find a way to have the Delegator component use some other
component with a template (chosen at runtime) to render output, and the
closest I found was using PageLoader's createImplicitComponent() function.
Is this correct for my intent? Are there more proper means of achieving the
same effect?

Technically I'm not trying to attach an implicit component to the page
dynamically - I simply want to be able to instantiate a regular component
with a template, and delegate rendering to it (or to one of several regular
components, chosen at runtime based on some criteria). 


Here's the code:

Home.java
[...]
@InjectObject(service:tapestry.page.PageLoader)
public abstract IPageLoader getPageLoader();

public IRender getDynamicComponent() {
return getComponent(whatever);
}

public void finishLoad(IRequestCycle cycle, IPageLoader loader,
IComponentSpecification specification) {
super.finishLoad(cycle, loader, specification);

IComponent iComponent =
getPageLoader().createImplicitComponent(getRequestCycle(), this, whatever,
layout/Test, getLocation());
this.addComponent(iComponent);
}
[...]


Home.html
[...]
span jwcid=@Delegator delegate=ognl:dynamicComponent/
[...]

This does delegate and produces output of whatever's in layout/Test
component's template.

Is there any downside to this approach (seems kinda hacky)? Or would a more
proper way be to actually implement my own IRender which reads from a
template somehow?


Thanks,
-p



___ 
Yahoo! Mail - Sempre a melhor opção para você! 
Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Dynamic components with template (? extends BaseComponent)

2007-03-16 Thread Portuendo Vestado
Darn you're right, I've never even thought of that. finishLoad(), which I'm
overriding to add the new implicit component, is called only once before the
page gets cached. So basically, my dynamic component is only dynamic the
first time template loads.

The reason I chose this method is that if you do it (that is, attach a
component via addComponent()) at render time, say in pageBeginRender(), it
hits AbstractComponent.checkActiveLock() sentinel and throws a Component
Home is active and its configuration state may not be changed, which is
quite reasonable.

I guess I'm still on the lookout for an option to delegate rendering to a
component with a template. There must be a way of instantiating those just
as simple as pages (i.e. with IRequestCycle.getPage(...)).

Btw, DynamicBlock you mentioned, is this it:
http://www.behindthesite.com/blog/C1931765677/E1630021481/? Does it work for
4.1 - seems a little old, September 2, 2004.


Thanks,
-P

--

I don't know enough about tapestry internals to say if this is a good 
idea, but I've played around with DynamicBlock and your solution looks a 
lot simpler.  At a guess, it looks like your approach is setting up your 
dynamic component when tapestry is loading the page template.  If it's 
part of tapestry template cache, that means it would only pick the 
dynamic content the first time the page is loaded and reuse the same 
component on every subsequent call to the page - unless you're running 
in dev mode with page caching disabled.  But as I said, that's a guess.

If I'm wrong, I want to know how well does it handle things like 
RenderBody and passing parameters to your component?  If it handles 
those concerns well, I'm tempted to wrap it up into a generic 
DynamicComponent.

If I'm right, it probably jives with Howard's vision of static 
structure/dynamic behavior, but may not function in the way you intended.

-Steve






___ 
Yahoo! Mail - Sempre a melhor opção para você! 
Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]