Please check the documentation about "informal parameters".  Basically, these 
are a back door that allow you, for most components, to specify additional HTML 
attributes as either static or dynamic properties.

In your case, you can create a component that subclasses AbstractComponent and 
provides a render method:

  public void render(IMarkupWriter write, IRequestCycle cycle)

This is how all the primitive components (Insert, Foreach, TextField, etc.) are 
written.

You can also mix and match (you can always mix and match in Tapestry).

The render method isn't defined in IComponent, it's defined in IRender.  If you 
want, you can have other classes do some of the response rendering.

There's a Delegator component.  Its delegate parameter must implement IRender.  
Doesn't have to be a component, just implement IRender and the render() method.

In your Calendar component case, the table(s) for the calendar itself might be 
easier to write in Java code than as HTML templates.

You'll notice that IMarkupWriter is like a PrintWriter (mostly) with some 
additional improvements related to writing out XML style tags and attributes.  
You won't have to worry about quotes and such.



--
[EMAIL PROTECTED]

http://tapestry.sf.net
> Hello,
> 
> Being a newbie to Tapestry I chose to get my feet wet by implementing a 
> little, however reasonably complex component - a calendar which should 
> be fully localized and provide a way to move forward and backward 
> monthwise, etc. I already have it implemented in struts/tiles, and 
> wanted to see how Tapestry fares.

I haven't looked at Tiles but those who have (and whose opinions I trust) 
tell me that they vastly prefer Tapestry.

> 
> As a first resume, I must say that Tapestry has a rather steep learning 
> curve - mostly caused by the multiple files one has to handle for each 
> and every little item (like implementing a foreach loop or a conditional 
> branch). Tiles tags are  definitely simpler to handle - and scripting a 
> JSP (or Velocity) is the easiest.

I think you'll like 2.4 ... it's a best of all worlds situation.  Less in the
page specification ... maybe no page specification at all.  You'll be able 
to do things like:

   <span jwcid="foreach:@Foreach" source="[[ itemsToDisplay ]]">
   <li><span jwcid="@Insert" value="[[ components.foreach.value ]]"/>
   </li>
   </span>

The [[ ... ]] surround an OGNL expression, much like a <binding> 
in a page specification.  The "@Type" syntax replaces the <component> entry in
the page specification.  You can leave many components anonymous.

It's a bit less of the "perfect, clean separation", but it's more practical
for many, especially those moving in from other environments.

2.4 is in active development, even as we try and roll out 2.3.


> 
> To some extent I can see this is due to the complex logic involved in 
> the problem. The calendar cannot be layed out statically in HTML, with 
> individual items replaced by business logic results - it requires a 
> nested loop with conditionals inside. Expressing this type of logic in a 
> template language is simply a pain (after all, this is what we have 
> programming languages for).
> Doing this in a html template language like Tapestry has almost only 
> drawbacks - the HTML becomes completely unmaintainable, both for humans 
> and for design tools, and runtime efficiency is also questionable.
> 
> OK, after ranting, heres my immediate questions:
> 
> 1. Is there a recommendation for situations as the above? Is there a way 
> to directly write parts of the component to the response stream from a 
> Java method when the logic becomes too complex?
> 
> 2. I need to also dynamically determine some tag attributes (i.e., 
> "class=" style attributes). In a JSP, I can write something like <td 
> class="<%=byBean.getStyle()%>">. How is this done with tapestry?
> 
> thanks,
> Christian Sell
> 
> 


-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to