[CONF] Apache Tapestry > Maven Support FAQ

2011-02-21 Thread confluence







Maven Support FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Maven Support  
...
   {code} 
  {scrollbar} 


Full Content

Hibernate Support FAQ Frequently Asked Questions 

Maven Support

Why do Maven project names and other details show up in my pages?

Tapestry and maven both use the same syntax for dynamic portions of files: the ${...} syntax.  When Maven is copying resources from src/main/resources, and when filtering is enabled (which is not the default), then any expansions in Tapestry templates that match against Maven project properties are substituted.  If you look at the deployed application you'll see that ${name} is gone, replaced with your project's name!

The solution is to update your pom.xml and ignore any .tml files when copying and filtering:

pom.xml (partial)

  
src/main/resources

  **/*.tml

true
  

  
src/main/resources

  **/*.tml

false
  




Hibernate Support FAQ Frequently Asked Questions 



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Hibernate Support FAQ

2011-02-21 Thread confluence







Hibernate Support FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Hibernate Support  
...
 This was a minor problem in 5.0; by 5.1 it is just a matter of overriding the configuration system {{tapestry.hibernate-early-startup}} to "true". 
 {scrollbar} 


Full Content

Specific Errors FAQ Frequently Asked Questions Maven Support FAQ

Hibernate Support

Main article: Hibernate

How do I get Hibernate to startup up when the application starts up, rather than lazily with the first request for the application?

This was a minor problem in 5.0; by 5.1 it is just a matter of overriding the configuration system tapestry.hibernate-early-startup to "true".

Specific Errors FAQ Frequently Asked Questions Maven Support FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Specific Errors FAQ

2011-02-21 Thread confluence







Specific Errors FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Specific Errors  
...
 !eclipse-permgen.png|thumbnail! 
 {scrollbar} 


Full Content

Limitations Frequently Asked Questions Hibernate Support FAQ

Specific Errors

Why do I get the exception "No service implements the interface org.apache.tapestry5.internal.InternalComponentResources" when trying to use the BeanEditForm component?

This can occur when you choose the wrong package for your data object, the object edited by the BeanEditForm component. If you place it in the same package as your pages, Tapestry will treat it like a page, and perform a number of transformation on it, including adding a new constructor.

Only component classes should go in the Tapestry-controlled packages (pages, components, mixins and base under your application's root package). By convention, simple data objects should go in a data package, and Hibernate entities should go in an entities package.

I get an error about "Page did not generate any markup when rendered." but I have a template, what happened?

The most common error here is that the case of the page class did not match the case of the template. For example, you might name your class ViewOrders, but name the template vieworders.tml.  The correct name for the template is ViewOrders.tml, matching the case of the Java class name.

Worse, you may find that your application works during development (under Windows, which is case insensitive) but does not work when deployed on a Linux or Unix server, which may be case sensitive.

The other cause of this may be that your template files simply are not being packaged up correctly with the rest of your application. When in doubt, use the Java jar command to see exactly whats inside your WAR file.  Your page templates should either be in the root folder of the WAR, or package with the corresponding .class file.

My application fails with the error PermGen, how do I fix this?

PermGen refers to the part of the Java memory space devoted to permanent objects, which are mostly loaded classes. When developing under Tapestry, many more classes and class loaders are created than normal; this is part of live class reloading. Because of this, you will want to increase the amount of memory Java devotes to this.

The solution is to add -XX:MaxPermSize=512m to your command line.  You may also want to increase the regular amount of heap space with -Xmx600M.  Of course, you may need to adjust the amount of memory in each category to match your actual application, but these are good starting values.

Java Virtual Machine arguments can be specified inside an Eclipse launch configuration:



Limitations Frequently Asked Questions Hibernate Support FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Integration with existing applications

2011-02-21 Thread confluence







Integration with existing applications
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Integration with existing applications  
...
The session is automatically created as needed.  
{scrollbar} 
  
...


Full Content

Tapestry Inversion of Control FAQ Frequently Asked Questions Limitations

Integration with existing applications

You may have an existing JSP (or Struts, Spring MVC, etc.) application that you want to migrate to Tapestry. It's quite common to do this in stages, moving some functionality into Tapestry and leaving other parts, initially, in the other system.

How do I make a form on a JSP submit into Tapestry?

Tapestry's Form component does a lot of work while an HTML form is rendering to store all the information needed to handle the form submission in a later request; this is all very specific to Tapestry and the particular construction of your pages and forms; it can't be reproduced from a JSP.

Fortunately, that isn't necessary: you can have a standard HTML Form submit to a Tapestry page, you just don't get to use all of Tapestry's built in conversion and validation logic.

All you need to know is how Tapestry converts page class names to page names (that appear in the URL).  It's basically a matter of stripping off the root-package.pages prefix from the fully qualified class name. So, for example, if you are building a login screen as a JSP, you might want to have a Tapestry page to receive the user name and password.  Let's assume the Tapestry page class is com.example.myapp.pages.LoginForm; the page name will be loginform




1


, and the URL will be /loginform.



"post" action="" class="code-quote">"/loginform">

  "text" value="userName"/>
  
  "password" value="password"/>
  
  "submit" value="Login"/>





On the Tapestry side, we can expect that the LoginForm page will be activated; this means that its activate event handler will be invoked.  We can leverage this, and Tapestry's RequestParameter annotation:



public class LoginForm
{
  void onActivate(@RequestParameter("userName") String userName, @RequestParameter("password") String password)
  {
 // Validate and store credentials, etc.
  }
}



The RequestParameter annotation extracts the named query parameter from the request, coerces its type from String to the parameter type (here, also String) and passes it into the method.


How do I share information between a JSP application and the Tapestry application?

From the servlet container's point of view, there's no difference between a servlet, a JSP, and an entire Tapestry application. They all share the same ServletContext, and (once created), the same HttpSession.

On the Tapestry side, it is very easy to read and write session attributes:



public class ShowSearchResults
{
  @SessionAttribute
  private SearchResults searchResults;
}



Reading the instance variable searchResults is instrumented to instead read the corresponding HttpSession attribute named "searchResults".  You can also specify the value attribute of the SessionAttribute annotation to override the default attribute name.

Writing to the field causes the corresponding HttpSession attribute to be modified.

The session is automatically created as needed.

Tapestry Inversion of Control FAQ Frequently Asked Questions Limitations




  Footnotes
  

  Reference
  Notes

  
  

  

1

  
  
  Tapestry is case insensitive, so LoginForm would work just as well.
  

  




Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Tapestry Inversion of Control FAQ

2011-02-21 Thread confluence







Tapestry Inversion of Control FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Tapestry Inversion of Control Container  
...
Be careful not to invoke methods on any service proxy objects as they will also be shutting down with the Registry. A RegistryShutdownListener should not be reliant on anything outside of itself. {note} 
 {scrollbar} 


Full Content

Injection FAQ Frequently Asked Questions Integration with existing applications

Tapestry Inversion of Control Container

Main article: Tapestry IoC


Related Articles


 Page:
 IoC





 Page:
 Tapestry IoC Overview





 Page:
 IoC cookbook





 Page:
 Tapestry Inversion of Control FAQ






Why do I need to define an interface for my services?  Why can't I just use the class itself?

First of all: you can do exactly this, but you lose some of the functionality that Tapestry's IoC container provides.

The reason for the split is so that Tapestry can provide functionality for your service around the core service implementation.  It does this by creating proxies: Java classes that implement the service interface.  The methods of the proxy will ultimately invoke the methods of your service implementation.

One of the primary purposes for proxies is to encapsulate the service's life cycle: most services are singletons that are created just in time.  Just in time means only as soon as you invoke a method.  What's going on is that the life cycle proxy (the object that gets injected into pages, components or other service implementations) checks on each method invocation to see if the actual service exists yet.  If not, it instantiates and configures it (using proper locking to ensure thread safety), then delegates the method invocation to the service.

If you bind a service class (not a service interface and class), then the service is fully instantiated the first time it is injected, rather than at that first method invocation. Further, you can't use decorations or method advice on such a service.

The final reason for the service interface / implementation split is to nudge you towards always coding to an interface, which has manifest benefits for code structure, robustness, and testability.

My service starts a thread; how do I know when the application is shutting down, to stop that thread?

This same concern applies to any long-lived resource (a thread, a database connection, a JMS queue connection) that a service may hold onto.  Your code needs to know when the application has been undeployed and shutdown.  This is actually quite easy, by adding some post-injection logic to your implementation class.



public class MyServiceImpl implements MyService, RegistryShutdownListener
{
  private boolean shuttingDown;

  private final Thread workerThread;

  public MyServiceImpl()
  {
workerThread = new Thread(. . .);
  }

  . . .

  @PostInjection
  public void startupService(RegistryShutdownHub shutdownHub)
  {
shutdownHub.addRegistryShutdownListener(this);
  }

  public void registryDidShutdown()
  {
shuttingDown = true;

workerThread.interrupt();
  } 
}



After Tapestry invokes the constructor of the service implementation, and after it performs any field injections, it invokes post injection methods. The methods must be public and return void.  Parameters to a post injection method represent further injections ... in the above example, the RegistryShutdownHub is injected into the PostInjection method, since it is only used inside that one method.

It is not recommended that MyServiceImpl take RegistryShutdownHub as a constructor parameter and register itself as a listener inside the constructor. Doing so is an example of unsafe publishing, a remote but potential thread safety issue.

This same technique will work for any kind of resource that must be cleaned up or destroyed when the registry shuts down.

Be careful not to invoke methods on any service proxy objects as they will also be shutting down with the Registry. A RegistryShutdownListener should not be reliant on anything outside of itself.

Injection FAQ Frequently Asked Questions Integration with exis

[CONF] Apache Tapestry > Ajax Components FAQ

2011-02-21 Thread confluence







Ajax Components FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Ajax Components  
...
 Instead, Tapestry creates a random-ish unique id suffix, such as "12a820cc40e" in the example; this suffix is appended to all allocated ids to ensure that they do not conflict with previously rendered ids. 
  {scrollbar} 


Full Content

_javascript_ FAQ Frequently Asked Questions Injection FAQ

Ajax Components

Main article: Ajax and Zones

Do I have to specify both id and t:id for Zone components?

The examples for the Zone component (in the Component Reference) consistently specify both id and t:id and this is probably a good idea.

Generally speaking, if you don't specify the client-side id (the id attribute), it will be the same as the Tapestry component id (t:id).

However, there are any number of exceptions to this rule. The Zone may be rendering inside a Loop (in which case, each rendering will have a unique client side id). The Zone may be rendering as part of a partial page render, in which case, a random unique id is inserted into the id. There are other examples where Tapestry component ids in nested components may also clash.

The point is, to be sure, specify the exact client id.  This will be the value for the zone parameter of the triggering component (such as a Form, PageLink, ActionLink, etc.).

How do I update the content of a Zone from an event handler method?

When a client-side link or form triggers an update, the return value from the event handler method is used to construct a partial page response; this partial page response includes markup content that is used to update the Zone's client-side  element.

Where does that content come from?  You inject it into your page.



"search" t:id="searchZone">
  "searchForm" zone="searchZone">
"query" size="20"/>
"submit" value="Search"/>
  


"searchResults">
  
"loop" source="searchHits" value="searchHit">${searchHit}
  






  @Inject
  private Block searchResults;

  Object onSuccessFromSearchForm()
  {
searchHits = searchService.performSearch(query);

return searchResults;
  }



So, when the search form is submitted, the resulting search hits are collected.  In the same request, the searchResults block is rendered, package, and sent to the client.  The form inside the client-side Zone  is replaced with the list of hits.

In many cases, you just want to re-render the Zone itself, to display updated content.  In that case, you don't need a separate , instead you can use @InjectComponent to inject the Zone object itself, and return the Zone's body:



  @InjectComponent
  private Zone statusZone;

  Object onActionFromUpdateStatus()
  {
return statusZone.getBody();
  }



How to I update multiple zones in a single event handler?

To do this, you must know, on the server, the client ids of each Zone. That's one of the reasons that you will generally set the Zone's client id (via the Zone's id parameter), rather than let Tapestry assign a client id for you.

From the event handler method, instead of returning a Block or a Component, return a multi-zone update:



  @Inject
  private Block searchResults;

  @Inject
  private Block statusBlock;

  Object onSuccessFromSearchForm()
  {
searchHits = searchService.performSearch(query);

message = String.format("Found %,d matching documents", searchHits.size());

return new MultiZoneUpdate("results", searchResults).add("status", statusBlock);
  }



What's that weird number in the middle of the client ids after a Zone is updated?

You might start with markup in your template for a component such as a TextField:



  "firstName"/>



When the component initially renders as part of a full page render, you get a sensible bit of markup:



  "firstName" name="firstName" type="text">



But when the form is inside a Zone and rendered as part of a zone update, the ids get weird:



   "firstName_12a820cc40e" name="firstName" type="text">



What's happening here is that Tapestry is working to prevent unwanted id clashes as part of the page update.  In an HTML document, each id is expected to be unique; most _javascript_ is keyed off of the id field, for instance.

In a full page render, components don't just use their component id (t:id) as their client id; instead they use the _javascript_Support environmental to allocate a unique id. When there's no loops or conflicts, the client id matches the component id.

When the component is inside a loop, a suffix is appended:  firstName, firstName_0, firstName_1, etc.

When the component is rendered as part of an Ajax partial page update, the rules are different. Since Tapestry doesn't know what content has been rendered onto the page previously, it can't

[CONF] Apache Tapestry > JavaScript FAQ

2011-02-21 Thread confluence







_javascript_ FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. _javascript_ 
 Main article: [_javascript_] 
...
 * First, check if 'tapestry.js' is present in the head part of your resulting HTML page. 
* If you have set the [tapestry.combine-scripts|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/SymbolConstants.html#COMBINE_SCRIPTS] configuration symbol to true, Tapestry generates one single URL to retrieve all the JS files. Sometimes, this can produce long URLs that browsers are unable to retrieve. Try setting the symbol to false. {note}This only applies to Tapestry 5.1.{note} 
* If you have included jQuery in conjunction with Tapestry's prototype, that will cause a conflict with the '$' selector used by both. In this case, you should put jQuery on top of the stack and turn on the [jQuery.noConflict|http://api.jquery.com/jQuery.noConflict/] mode. * Also, if you have included a custom or third-party JS library on top of the stack that causes the _javascript_ parsing to fail, then check the _javascript_ syntax in that library. 
...


Full Content

Link Components FAQ Frequently Asked Questions Ajax Components FAQ

_javascript_

Main article: _javascript_

Why do I get a "Tapestry is undefined" error on form submit?

This client-side error is clear but can be awkward to solve. It means your browser has not been able to load the tapestry.js file properly. The question is, why? It can be due to multiple reasons, some of them below:


	First, check if 'tapestry.js' is present in the head part of your resulting HTML page.
	If you have set the tapestry.combine-scripts configuration symbol to true, Tapestry generates one single URL to retrieve all the JS files. Sometimes, this can produce long URLs that browsers are unable to retrieve. Try setting the symbol to false. 
This only applies to Tapestry 5.1.
	If you have included jQuery in conjunction with Tapestry's prototype, that will cause a conflict with the '$' selector used by both. In this case, you should put jQuery on top of the stack and turn on the jQuery.noConflict mode.
	Also, if you have included a custom or third-party JS library on top of the stack that causes the _javascript_ parsing to fail, then check the _javascript_ syntax in that library.
	If you have used a tool to minimize your _javascript_ libraries, this can lead to _javascript_ syntax errors, so check if it works with all the _javascript_ files unpacked.




Link Components FAQ Frequently Asked Questions Ajax Components FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > JavaScript FAQ

2011-02-21 Thread confluence







_javascript_ FAQ
Page edited by Howard M. Lewis Ship


 Changes (5)
 




h2. _javascript_ 
{scrollbar} 
 
h2. _javascript_  
Main article: [_javascript_]  
h3. Why do i I get a "Tapestry is undefined" error on form submit? 
 This client-side error is clear but can be awkward to solve. It means your browser has not been able to load the tapestry.js file properly. The question is, why? It can be due to multiple reasons, some of them below: 
...
* Also, if you have included a custom or third-party JS library on top of the stack that causes the _javascript_ parsing to fail, then check the _javascript_ syntax in that library. * If you have used a tool to minimize your _javascript_ libraries, this can lead to _javascript_ syntax errors, so check if it works with all the _javascript_ files unpacked. 
  {scrollbar} 


Full Content

Link Components FAQ Frequently Asked Questions Ajax Components FAQ

_javascript_

Main article: _javascript_

Why do I get a "Tapestry is undefined" error on form submit?

This client-side error is clear but can be awkward to solve. It means your browser has not been able to load the tapestry.js file properly. The question is, why? It can be due to multiple reasons, some of them below:


	First, check if 'tapestry.js' is present in the head part of your resulting HTML page.
	If you have set the tapestry.combine-scripts configuration symbol to true, Tapestry generates one single URL to retrieve all the JS files. Sometimes, this can produce long URLs that browsers are unable to retrieve. Try setting the symbol to false.
	If you have included jQuery in conjunction with Tapestry's prototype, that will cause a conflict with the '$' selector used by both. In this case, you should put jQuery on top of the stack and turn on the jQuery.noConflict mode.
	Also, if you have included a custom or third-party JS library on top of the stack that causes the _javascript_ parsing to fail, then check the _javascript_ syntax in that library.
	If you have used a tool to minimize your _javascript_ libraries, this can lead to _javascript_ syntax errors, so check if it works with all the _javascript_ files unpacked.




Link Components FAQ Frequently Asked Questions Ajax Components FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Link Components FAQ

2011-02-21 Thread confluence







Link Components FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Link Components  
...
 A similar technique can be used to add query parmeters to component event URLs (the type generated by the ActionLink or EventLink components), by injecting the ComponentResources, and invoking method {{createEventLink()}}. 
  {scrollbar} 


Full Content

Forms and Form Components Frequently Asked Questions _javascript_ FAQ

Link Components

How do I add query parameters to a PageLink or ActionLink?

These components do not have parameters to allow you to specify query parameters for the link; they both allow you to specify a context (one or more values to encode into the request path).

However, you can accomplish the same thing with a little code and markup.  For example, to create a link to another page and pass a query parameter, you can replace your PageLink component with a standard  tag:



"${profilePageLink}">Display Profile (w/ full details)



In the matching Java class, you can create the Link programmatically:



  @Inject
  private PageRenderLinkSource linkSource;

  public Link getProfilePageLink()
  {
Link link = linkSource.createPageRenderLinkWithContext(DisplayProfile.class, user);

link.addParameterValue("detail", true);

return link;
  }



... and in the DisplayProfile page:



public class DisplayProfile
{
  void onActivate(@RequestParameter("detail") boolean detail)
  {
. . .
  }
}



The @RequestParameter annotation directs Tapestry to extract the query parameter from the request and coerce it to type boolean.  You can use any reasonable type for such a parameter (int, long and Date are common).

A similar technique can be used to add query parmeters to component event URLs (the type generated by the ActionLink or EventLink components), by injecting the ComponentResources, and invoking method createEventLink().


Forms and Form Components Frequently Asked Questions _javascript_ FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Forms and Form Components

2011-02-21 Thread confluence







Forms and Form Components
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Forms and Form Components  
...
 The "prop:" prefix identifies that "usernameLabel" is to be interpreted as a property _expression_ (normally, the binding for the {{label}} parameter is interpreted as a string literal).  The Label component gets the text it displays from the TextField component, and the TextField component uses the same text when generating server-side and client-side validation messages. 
  {scrollbar} 


Full Content

Page And Component Classes FAQ Frequently Asked Questions Link Components FAQ

Forms and Form Components

What is the t:formdata hidden field for?

In Tapestry, rendering a form can be a complicated process; inside the body of the Form component are many of field components: TextField, Select, TextArea, and so forth. Each of these must pull data out of your data model and convert it to the string form used inside the client web browser.  In addition, _javascript_ to support client-side validation must be generated.  This can be further complicated by the use of Loop and If components, or made really complicated by the use of Block (to render portions of other pages: this is what the BeanEditForm component does).

Along the way, the Form is generating unique form control names for each field component, as it renders.

When the client-side Form is submitted, an event is triggered on the server-side Form component. It now needs to locate each component, in turn, inform the component of its control name, and allow the component to read the corresponding query parameter. The component then converts the client-side string back into a server-side value and performs validations before updating the data model.

That's where t:formdata comes in.  While components are rendering, they are using the FormSupport environmental object to record callbacks:

FormSupport.java (partial)

public interface FormSupport extends ClientElement
{
/**
 * Stores an action for execution during a later request.  If the action contains any mutable state, it should be in
 * its final state before invoking this method and its internal state should not be changed subsequently.
 */
 void store(T component, ComponentAction action);

/**
 * As with {@link #store(Object, org.apache.tapestry5.ComponentAction)}}, but the action is also invoked
 * immediately. This is useful for defining an action that should occur symmetrically in both the render request and
 * the form submission's event request.
 *
 * @param component component against which to trigger the action
 * @param actionthe action that will be triggered (and passed the component)
 */
 void storeAndExecute(T component, ComponentAction action);



The ComponentAction objects are the callbacks.  t:formdata is simply an object stream of these callbacks, compressed and encoded in Base64.  When using Ajax, you may see multiple t:formdata hidden fields (they are processed one after another).


How do I change the label for a field on the fly?


Tapestry tries to be smart about generating the label string for a field.  It has some smart default logic, first checking for the component-id-label in the container's message catalog, then ultimately converting the component's id into a user-presentable label.

You can override the label in two ways:

First, you can supply a body to the Label component:



  for="username">${usernameLabel}
  "username"/>



Here, the component class must provide a usernameLabel property. That property becomes the text of the label. An implementation of the property might look something like:



  public String getUsernameLabel()
  {
return systemPreferences.useEmailAddressForUserName() ? "Email address" : "User name";
  }



However, if there are any validations on the field, the error message will include the default label (as discussed above).

To uniformly update the label both on the page, and in any validation messages, bind the TextField's label parameter:



  for="username"/>
  "username" label="prop:usernameLabel"/>



The "prop:" prefix identifies that "usernameLabel" is to be interpreted as a property _expression_ (normally, the binding for the label parameter is interpreted as a string literal).  The Label component gets the text it displays from the TextField component, and the TextField component uses the same text when generating server-side and client-side validation messages.


Page And Component Classes FAQ Frequently Asked Questions Link Components FAQ



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Page And Component Classes FAQ

2011-02-21 Thread confluence







Page And Component Classes FAQ
Page edited by Howard M. Lewis Ship


 Changes (1)
 




{scrollbar}  
h2. Page And Component Classes 
 Main article: [Component Classes] 
...


Full Content

Templating and Markup FAQ Frequently Asked Questions Forms and Form Components

Page And Component Classes

Main article: Component Classes

What's the difference between a page and a component?

There's very little difference between the two. Pages classes must be in the root-package.pages package; components must be in the root-package.components.  Pages may provide event handlers for certain page-specific events (such as activate and passivate).  Components may have parameters.

Other than that, they are more equal than they are different. They may have templates or may render themselves in code (pages usually have a template, components are more likely to render only in code).

The major difference is that Tapestry page templates may be stored in the web context directory, as if they were static files (they can't be accessed from the client however; a specific rule prevents access to files with the .tml extension).

It is possible that this feature may be removed in a later release. It is preferred that page templates be stored on the classpath, like component templates.

How do I store my page classes in a different package?

Tapestry is very rigid here; you can't. Page classes must go in root-package.pages, component classes in root-package.components, etc.

You are allowed to create sub-packages, to help organize your code better and more logically. For example, you might have _root-package.pages.account.ViewAccount, which would have the page name "account/viewaccount"




1




In addition, it is possible to define additional root packages for the application:



public static void contributeComponentClassResolver(Configuration configuration) {
   configuration.add(new LibraryMapping("", "com.example.app.tasks"));
   configuration.add(new LibraryMapping("", "com.example.app.chat"));
}



LibraryMappings are used to resolve a library prefix to one or more package names.  The empty string represents the application itself; the above example adds two additional root packages; you might see additional pages under com.example.app.tasks.pages, for example.

Tapestry doesn't check for name collisions, and the order the packages are searched for pages and components is not defined. In general, if you can get by with a single root package for your application, that is better.

Why do my instance variables have to be private?

Tapestry does a large amount of transformation to your simple POJO classes as it loads them into memory. In many cases, it must locate every read or write of an instance variable and change its behavior; for example, reading a field that is a component parameter will cause a property of the containing page or component to be read.

Limiting fields to private means that Tapestry can do the necessary processing one class at a time, as needed, at runtime. More complex Aspect Orient Programming systems such as AspectJ can perform similar transformations (and much more complex ones), but requires a dedicated build step (or the introduction of a JVM agent).

Why don't my informal parameters show up in the rendered markup?

Getting informal parameters to work is in two steps.  First, you must make a call to the ComponentResources.renderInformalParameters() method, but just as importantly, you must tell Tapestry that you want the component to support informal parameters, using the SupportsInformalParameters annotation. Here's a hypothetical component that displays an image based on the value of a Image object (presumably, a database entity):



@SupportsInformalParameters
public class DBImage
{
  @Parameter(required=true)
  private Image image;

  @Inject
  private ComponentResources resources;

  boolean beginRender(MarkupWriter writer)
  {
writer.element("img", "src", image.toClientURL(), "class", "db-image");

resources.renderInformalParameters(writer);

writer.end();

return false;
  }
}




Why do I get java.lang.LinkageError when I invoke public methods of my page classes?

In Tapestry, there are always two versions of page (or component) classes.  The first version is the version loaded by standard class loader: the simple POJO version that you wrote.

The second version is much more complicated; it's the transformed version of your code, with lots of extra hooks and changes to allow the class to operate inside Tapestry. This includes implementing new interfaces and methods, adding new constructors, and changing access to existing fields and methods.

Although these two classes have the same fully qualified cl

[CONF] Apache Tapestry > Page And Component Classes FAQ

2011-02-21 Thread confluence







Page And Component Classes FAQ
Page edited by Howard M. Lewis Ship


 Changes (1)
 




...
There's very little difference between the two. Pages classes must be in the _root-package_.{{pages}} package; components must be in the _root-package_.{{components}}.  Pages may provide event handlers for certain page-specific events (such as activate and passivate).  Components may have parameters.  
Other than that, they are more equal than they are different. They may have templates or may render themselves in code (pages usually have a template, components are more likely to render only in code). 
 The major difference is that Tapestry page templates may be stored in the web context directory, as if they were static files (they can't be accessed from the client however; a specific rule prevents access to files with the {{.tml}} extension). 
...


Full Content

Templating and Markup FAQ Frequently Asked Questions Forms and Form Components

Page And Component Classes

Main article: Component Classes

What's the difference between a page and a component?

There's very little difference between the two. Pages classes must be in the root-package.pages package; components must be in the root-package.components.  Pages may provide event handlers for certain page-specific events (such as activate and passivate).  Components may have parameters.

Other than that, they are more equal than they are different. They may have templates or may render themselves in code (pages usually have a template, components are more likely to render only in code).

The major difference is that Tapestry page templates may be stored in the web context directory, as if they were static files (they can't be accessed from the client however; a specific rule prevents access to files with the .tml extension).

It is possible that this feature may be removed in a later release. It is preferred that page templates be stored on the classpath, like component templates.

How do I store my page classes in a different package?

Tapestry is very rigid here; you can't. Page classes must go in root-package.pages, component classes in root-package.components, etc.

You are allowed to create sub-packages, to help organize your code better and more logically. For example, you might have _root-package.pages.account.ViewAccount, which would have the page name "account/viewaccount"




1




In addition, it is possible to define additional root packages for the application:



public static void contributeComponentClassResolver(Configuration configuration) {
   configuration.add(new LibraryMapping("", "com.example.app.tasks"));
   configuration.add(new LibraryMapping("", "com.example.app.chat"));
}



LibraryMappings are used to resolve a library prefix to one or more package names.  The empty string represents the application itself; the above example adds two additional root packages; you might see additional pages under com.example.app.tasks.pages, for example.

Tapestry doesn't check for name collisions, and the order the packages are searched for pages and components is not defined. In general, if you can get by with a single root package for your application, that is better.

Why do my instance variables have to be private?

Tapestry does a large amount of transformation to your simple POJO classes as it loads them into memory. In many cases, it must locate every read or write of an instance variable and change its behavior; for example, reading a field that is a component parameter will cause a property of the containing page or component to be read.

Limiting fields to private means that Tapestry can do the necessary processing one class at a time, as needed, at runtime. More complex Aspect Orient Programming systems such as AspectJ can perform similar transformations (and much more complex ones), but requires a dedicated build step (or the introduction of a JVM agent).

Why don't my informal parameters show up in the rendered markup?

Getting informal parameters to work is in two steps.  First, you must make a call to the ComponentResources.renderInformalParameters() method, but just as importantly, you must tell Tapestry that you want the component to support informal parameters, using the SupportsInformalParameters annotation. Here's a hypothetical component that displays an image based on the value of a Image object (presumably, a database entity):



@SupportsInformalParameters
public class DBImage
{
  @Parameter(required=true)
  private Image image;

  @Inject
  private ComponentResources resources;

  boolean beginRender(MarkupWriter writer)
  {
writer.element("img", "src", image.toClientURL(), "class", "db-image");

resources.renderInformalParameters(w

[CONF] Apache Tapestry > Page And Component Classes FAQ

2011-02-21 Thread confluence







Page And Component Classes FAQ
Page edited by Howard M. Lewis Ship


 Changes (5)
 




h2. Page And Component Classes 
{scrollbar} 
 
h2. Page And Component Classes  
Main article: [Component Classes]  
...
There's very little difference between the two. Pages classes must be in the _root-package_.{{pages}} package; components must be in the _root-package_.{{components}}.  Pages may provide event handlers for certain page-specific events (such as activate and passivate).  Components may have parameters.  
Other than that, they are more equal than they are different. They may have templates or may render themselves in code (pages usually have a template, components are more likely to render only in code). 
 The major difference is that Tapestry page templates may be stored in the web context directory, as if they were static files (they can't be accessed from the client however; a specific rule prevents access to files with the {{.tml}} extension). 
...
Tapestry tranforms your class at runtime. It tends to build a large constructor for the class instance. Further, an instance of the class is useless by itself, it must be wired together with its template and its sub-components.   
{scrollbar}  
  
...


Full Content

Templating and Markup FAQ Frequently Asked Questions Forms and Form Components

Page And Component Classes

Main article: Component Classes

What's the difference between a page and a component?

There's very little difference between the two. Pages classes must be in the root-package.pages package; components must be in the root-package.components.  Pages may provide event handlers for certain page-specific events (such as activate and passivate).  Components may have parameters.

Other than that, they are more equal than they are different. They may have templates or may render themselves in code (pages usually have a template, components are more likely to render only in code).

The major difference is that Tapestry page templates may be stored in the web context directory, as if they were static files (they can't be accessed from the client however; a specific rule prevents access to files with the .tml extension).

It is possible that this feature may be removed in a later release. It is preferred that page templates be stored on the classpath, like component templates.

How do I store my page classes in a different package?

Tapestry is very rigid here; you can't. Page classes must go in root-package.pages, component classes in root-package.components, etc.

You are allowed to create sub-packages, to help organize your code better and more logically. For example, you might have _root-package.pages.account.ViewAccount, which would have the page name "account/viewaccount"




1




In addition, it is possible to define additional root packages for the application:



public static void contributeComponentClassResolver(Configuration configuration) {
   configuration.add(new LibraryMapping("", "com.example.app.tasks"));
   configuration.add(new LibraryMapping("", "com.example.app.chat"));
}



LibraryMappings are used to resolve a library prefix to one or more package names.  The empty string represents the application itself; the above example adds two additional root packages; you might see additional pages under com.example.app.tasks.pages, for example.

Tapestry doesn't check for name collisions, and the order the packages are searched for pages and components is not defined. In general, if you can get by with a single root package for your application, that is better.

Why do my instance variables have to be private?

Tapestry does a large amount of transformation to your simple POJO classes as it loads them into memory. In many cases, it must locate every read or write of an instance variable and change its behavior; for example, reading a field that is a component parameter will cause a property of the containing page or component to be read.

Limiting fields to private means that Tapestry can do the necessary processing one class at a time, as needed, at runtime. More complex Aspect Orient Programming systems such as AspectJ can perform similar transformations (and much more complex ones), but requires a dedicated build step (or the introduction of a JVM agent).

Why don't my informal parameters show up in the rendered markup?

Getting informal parameters to work is in two steps.  First, you must make a call to the ComponentResources.renderInformalParameters() method, but just as importantly, you must tell Tapestry that you want the component to support informal parameters, using the

[CONF] Apache Tapestry > Templating and Markup FAQ

2011-02-21 Thread confluence







Templating and Markup FAQ
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{scrollbar}  
h2. Templating and Markup  
...
  
{scrollbar} 
  
...


Full Content

General Questions Frequently Asked Questions Page And Component Classes FAQ

Templating and Markup

Main Article: Component Templates

Why do I get a SAXParseException when I use an HTML entity, such as   in my template?

Tapestry uses a standard SAX parser to read your templates. This means that your templates must be well formed: open and close tags must balance, attribute values must be quoted, and entities must be declared. The easiest way to accomplish this is to add a DOCTYPE to your the top of your template:



"-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



Part of the DOCTYPE is the declaration of entities such as  .

Alternately, you can simply use the numeric version:  ;  This is the exact same character and will render identically in the browser.


Why do some images in my page show up as broken links?

You have to be careful when using relative URLs inside page templates; the base URL may not always be what you expect.  For example, inside your ViewUser.tml file, you may have:



  "icon" src="" class="code-quote">"icons/admin.png"/>${user.name} has Administrative access



This makes sense; ViewUser.tml is in the web context, as is the icons folder.  The default URL for this page will be /viewuser




1




However, most likely, the ViewUser page has a page activation context to identify which user is to be displayed:



public class ViewUser

  @Property
  @PageActivationContext
  private User user;

  . . .



With a page activation context, the URL for the page will incorporate the id of the User object, something like /viewuser/37371.  This is why the relative URLs to the admin.png image is broken: the base path is relative to the page's URL, not to the page template


2


.

One solution would be to predict what the page URL will be, and adjust the path for that:



  "icon" src="" class="code-quote">"../icons/admin.png"/>${user.name} has Administrative access



But this has its own problems; the page activation context may vary in length at different times, or the template in question may be a component used across many different pages, making it difficult to predict what the correct relative URL would be.

The best solution for this situation, one that will be sure to work in all pages and all components, is to make use of the context: binding prefix:



  "icon" src="" class="code-quote">"${context:icons/admin.png}"/>${user.name} has Administrative access



The src attribute of the  tag will now be bound to a dynamically computed value: the location of the image file relative to the web application context. This is especially important for components that may be used on different pages.

What's the difference between id and t:id?

You might occasionally see something like the following in a template:



"status" t:id="statusZone">



Why two ids?  Why are they different?

The t:id attribute is the Tapestry component id. This id is unique within its immediate container.  This is the id you might use to inject the component into your page class:



  @InjectComponent
  private Zone statusZone;



The other id is the client id, a unique id for the rendered element within the client-side DOM. _javascript_ that needs to access the element uses this id.  For example:



  $('status').hide();



In many components, the id attribute is an informal parameter; a value from the template that is blindly echoed into the output document.  In other cases, the component itself has an id attribute.  Often, in the latter case, the Tapestry component id is the default value for the client id.


Why do my images and stylesheets end up with a weird URLs like /assets/eea17aee26bc0cae/ctx/layout/layout.css?

Tapestry doesn't rely on the servlet container to serve up your static assets (images, stylesheets, flash movies, etc.).  Instead, if builds a URL that Tapestry processed itself.

The content that is sent to the browser will be GZIP compressed (if the client supports compression). In addition, Tapestry will set a far-future expires header on the content. This means that the browser will not ask for the file again, greatly reducing network traffic.

The wierd hex string is a random application version number.  A new one is chosen every time the application starts up.

This is necessary so that, if an asset changes in place, browsers will download the new version.  Because the application version number has changed, it represents a new asset to browsers, who will download 

[CONF] Apache Tapestry > General Questions

2011-02-21 Thread confluence







General Questions
Page edited by Howard M. Lewis Ship


 Changes (3)
 




{scrollbar}  
h2. General Questions  
...
However, the stronger reason for Request (and the related interfaces Response and Session) is to enable the support for Portlets at some point in the future. By writing code in terms of Tapestry's Request, and not HttpServletRequest, you can be assured that the same code will operate in both Servlet Tapestry and Portlet Tapestry.  
 {scrollbar} 
{display-footnotes} 


Full Content

 Frequently Asked Questions Templating and Markup FAQ

General Questions

How do I get started with Tapestry?

The easiest way to get started is to use Apache Maven to create your initial project; Maven can use an archetype (a kind of project template) to create a bare-bones Tapestry application for you.  See the Getting Started page for more details.

Even without Maven, Tapestry is quite easy to set up.  You just need to download the binaries and setup your build to place them inside your WAR's WEB-INF/lib folder. The rest is just some one-time configuration of the web.xml deployment descriptor.

Why does Tapestry use Prototype?  Why not insert favorite _javascript_ library here?

An important goal for Tapestry is seamless DHTML and Ajax integration. To serve that goal, it was important that the built in components be capable of Ajax operations, such as dynamically re-rendering parts of the page. Because of that, it made sense to bundle a well-known _javascript_ library as part of Tapestry.

At the time (this would be 2006-ish), Prototype and Scriptaculous were well known and well documented, and jQuery was just getting started.

The intent has always been to make this aspect of Tapestry pluggable. This is work expected in Tapestry 5.3, where a kind of adapter layer will be introduced so that Tapestry can be easily customized to work with any of the major _javascript_ libraries.  

Why does Tapestry have its own Inversion of Control Container?  Why not Spring or Guice?

An Inversion of Control Container is the key piece of Tapestry's infrastructure. It is absolutely necessary to create software as robust, performant and extensible as Tapestry.

Tapestry IoC includes a number of features that distinguish itself from other containers:

	Configured in code, not XML
	Built-in extension mechanism for services: configurations and contributions
	Built-in aspect oriented programming model (service decorations and advice)
	Easy modularization
	Best-of-breed exception reporting



Because Tapestry is implemented on top of its IoC container, and because the container makes it easy to extend or replace any service inside the container, it is possible to make the small changes to Tapestry needed to customize it to any project's needs.

How do I upgrade from Tapestry 4 to Tapestry 5?

There is no existing tool that supports upgrading from Tapestry 4 to Tapestry 5; Tapestry 5 is a complete rewrite.

Many of the basic concepts in Tapestry 4 are still present in Tapestry 5, but refactored, improved, streamlined, and simplified.  The basic concept of pages, templates and components are largely the same. Other aspects, such as server-side event handling, is markedly different.

Why are there both Request and HttpServletRequest?

Tapestry's Request interface is very close to the standard HttpServletRequest interface. It differs in a few ways, omitting some unneeded methods, and adding a couple of new methods (such as isXHR()), as well as changing how some existing methods operate. For example, getParameterNames() returns a sorted List of Strings; HttpServletRequest returns an Enumeration, which is a very dated approach.

However, the stronger reason for Request (and the related interfaces Response and Session) is to enable the support for Portlets at some point in the future. By writing code in terms of Tapestry's Request, and not HttpServletRequest, you can be assured that the same code will operate in both Servlet Tapestry and Portlet Tapestry.

 Frequently Asked Questions Templating and Markup FAQ





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Frequently Asked Questions

2011-02-21 Thread confluence







Frequently Asked Questions
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{toc} {children} 
 
{include:General Questions} {include:Templating and Markup FAQ} {include:Page And Component Classes FAQ} {include:Forms and Form Components} {include:Link Components FAQ} {include:_javascript_ FAQ} {include:Ajax Components FAQ} {include:Injection FAQ} {include:Tapestry Inversion of Control FAQ} {include:Integration with existing applications} {include:Specific Errors FAQ} {include:Limitations} {include:Hibernate Support FAQ} {include:Maven Support FAQ} 
{htmlcomment}Update here after adding new headings to child pages. Forces a rebuild of the main TOC.  
...


Full Content

General QuestionsTemplating and Markup FAQPage And Component Classes FAQForms and Form ComponentsLink Components FAQ_javascript_ FAQAjax Components FAQInjection FAQTapestry Inversion of Control FAQIntegration with existing applicationsLimitationsSpecific Errors FAQHibernate Support FAQMaven Support FAQ





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Frequently Asked Questions

2011-02-21 Thread confluence







Frequently Asked Questions
Page edited by Howard M. Lewis Ship


 Changes (2)
 




{toc} {children} 
 
{include:General Questions} {include:Templating and Markup FAQ} {include:Page And Component Classes FAQ} {include:Forms and Form Components} {include:Link Components FAQ} {include:_javascript_ FAQ} {include:Ajax Components FAQ} {include:Injection FAQ} {include:Tapestry Inversion of Control FAQ} {include:Integration with existing applications} {include:Specific Errors FAQ} {include:Limitations} {include:Hibernate Support FAQ} {include:Maven Support FAQ} 
{htmlcomment}Update here after adding new headings to child pages. Forces a rebuild of the main TOC.  
...


Full Content

General QuestionsTemplating and Markup FAQPage And Component Classes FAQForms and Form ComponentsLink Components FAQ_javascript_ FAQAjax Components FAQInjection FAQTapestry Inversion of Control FAQIntegration with existing applicationsLimitationsSpecific Errors FAQHibernate Support FAQMaven Support FAQ





Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Injection FAQ

2011-02-21 Thread confluence







Injection FAQ
Page edited by Howard M. Lewis Ship


 Changes (15)
 




...
Main article: [Injection]  
h3. What's the difference between the {{@Component}} and {{@InjectComponent}} annotations? 
 
The {{@Component}} annotation is used to define the _type_ of component, and its parameter bindings. When using {{@Component}}, the template must not define the type, and any parameter bindings are merged in: 
 {code:controls=true|linenumbers=true} 
...
Here the type of component is defined by the field type. The field name is matched against the {{t:id}} in the template. The {{page}} parameter is set in the Java class, and the informal {{class}} parameter is set in the template.  If the tag in the template was {{}}, or if the template tag included the attribute {{t:type="pagelink"}}, then you would see an exception.  
By contrast, {{@InjectComponent}} expects the component to be already defined, and doesn't allow any configuration of it: 
 {code:controls=true|linenumbers=true} 
...
Again, we're matching the field name to the component id, and you would get an error if the component is not defined in the template.  
h3. What's the difference between the {{@InjectPage}} and {{@InjectContainer}} annotations? 
 
The {{@InjectPage}} annotation is used to inject some page in the application into a field of some other page.  You often see it used from event handler methods: 
 {code:controls=true|linenumbers=true} 
...
This code pattern is used to configure peristent properties of a page before returning it; Tapestry will send a client redirect to the page to present the data.  
{{@InjectContainer}} can be used inside a component or a mixin.  In a component, it injects the immediate container of the component; this is often the top-level page object. 
 In a mixin, it injects the component to which the mixin is attached. 
...
{code}  
The two marker annotations, {{@Traditional}} and {{@Primary}}, ensure that only a single service matches. 
 
h3. What's the difference between {{@Inject}} and {{@Environmental}}? 
 
{{@Inject}} is relatively general; it can be used to inject resources specific to a page or component (such as ComponentResources, Logger, or Messages), or it can inject services or other objects obtained from the Tapestry IoC container.  Once the page is loaded, the values for these injections never change. 
 
{{@Environmental}} is different; it exposes a request-scoped, dynamically bound value{footnote}. The term "Environmental" was chosen as the value "comes from the environment", whatever that means. A name more evocative of its function still has not occurred to the Tapestry team!{footnote}. 
 * Request scoped: different threads (processing different requests) will see different values when reading the field. 
...
Environmentals are a form of loosely connected communication between an outer component (or even a service) and an inner component.  Example: the Form component places a {{FormSupport}} object into the environment.  Other components, such as TextField, use the {{FormSupport}} when rendering to perform functions such as allocate unique control names or register client-side validations.  The TextField doesn't require that the Form component be the immediate container component, or even an ancestor: a Form on one page may, indirectly, communicate with a TextField on some entirely different page. Neither component directly links to the other, the {{FormSupport}} is the conduit that connects them.  
h3. I use @Inject on a field to inject a service, but the field is still null, what happened? 
h3. But wait ... I see I used the {{@Inject}} annotation and it still worked. What gives? 
 
This can happen when you use the wrong @Inject annotation; for example, com.google.inject.Inject instead of org.apache.tapestry5.ioc.annotations.Inject.  This can occur when you have TestNG on the classpath, for example, and your IDE is too helpful.  Double check your imports when things seem weird. 
In certain cases, Tapestry exposes a service (which can be injected) that is a proxy to the environmental; this is primarily for common environmentals, such as [_javascript_Support|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/_javascript_/_javascript_Support.html], that may be needed outside of component classes.  You can see this in TapestryModule: 
 
{code:Java|title=TapestryModule.java (partial)} /**  * Buil

[CONF] Apache Tapestry > Component Templates

2011-02-21 Thread confluence







Component Templates
Page edited by Bob Harner


Comment:
Updated HTML5 wording after Josh Canfield fixed https://issues.apache.org/jira/browse/TAP5-1040.  Thanks, Josh!


 Changes (4)
 




...
   "http://www.w3.org/TR/html4/loose.dtd"> 
  
{code}  
What about HTML5?  Well, as of version 5.2 Tapestry doesn't yet support the HTML5 doctype directly (see [TAP5-1040|https://issues.apache.org/jira/browse/TAP5-1040]), but there's a partial work-around: just add the following to your page class (or your layout class, if you use one): 
That last one is for HTML5.  Unfortunately, in version 5.2 and earlier, Tapestry didn't support the HTML5 doctype directly (see [TAP5-1040|https://issues.apache.org/jira/browse/TAP5-1040]), but there's a partial work-around: just add the following to your page class (or your layout class, if you use one) _instead of_ adding the doctype to your template (.tml) files: 
 {code} 
...
{code}  
Note that this allows you to use emit HTML5 to the browser, but the problem of [entities not working ([TAP5-840|https://issues.apache.org/jira/browse/TAP5-840]) remains. 
 h2. The Tapestry Namespace 
...


Full Content

Component Templates


Related Articles


 Page:
 Templating and Markup FAQ





 Page:
 Component Parameters





 Page:
 Component Libraries





 Page:
 Component Classes





 Page:
 Component Reference




 

Under Tapestry, a component template is the file that contains the markup for that page or component.

Component templates are well formed XML documents. That means that every open tag must have a matching close tag, every attribute must be quoted, and so forth.

At runtime, Tapestry parses the documents and only checks for wellformedness. Even when the document has a DTD or schema, there are no validity checks.

For the most part, these templates are standard HTML/XHTML; Tapestry extensions to ordinary markup are provided in the form of a Tapestry namespace.

We'll cover the specific content of templates shortly, first a few details about connecting a component to its template.

Template Location

Component templates are stored with the component class file. The files have a ".tml" extension (i.e., Tapestry Markup Language), and are stored in the same package as corresponding component class.

Under a typical Maven directory structure, the Java class for a component might be src/main/java/org/example/myapp/components/MyComponent.java. The corresponding template will be src/main/resources/org/example/myapp/components/MyComponent.tml.

Likewise, the Java class for a page might be src/main/java/org/example/myapp/pages/MyPage.java and the corresponding template will be src/main/resources/org/example/myapp/pages/MyPage.tml.

The template and the compiled class will be packaged together in the WEB-INF/classes folder of the application WAR.

For pages (not components), a second location will be searched: in the web application context. The location is based on the logical name of the page, in the previous example, the template would be MyPage.tml in the root folder of the web application.

A template on the classpath takes precedence over a file in the web application context.

Allowing pages to store their template in the web context is a feature that may go away at some point. It was included as a way for HTML designers to edit template directly and live preview the template directly, without executing the Tapestry application. This comes with a large number of limitations and leads to a false sense of security that a template that previews correctly will render properly (this is not always the case).

In certain cases, Tapestry will simplify the the logical name of a page. For example, the page class org.example.pages.address.CreateAddress will be given a logical name of "address/Create" (the redundant "Address" is removed as a suffix). However, this only affects how the page

[jira] Commented: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Hudson (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12997574#comment-12997574
 ] 

Hudson commented on TAP5-1040:
--

Integrated in tapestry-5.2-freestyle #267 (See 
[https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/267/])
TAP5-1040 - integrated patch to allow no system or public id in doctype


> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Assignee: Josh Canfield
>Priority: Minor
> Fix For: 5.3.0, 5.2.5
>
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] Resolved: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Josh Canfield (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Josh Canfield resolved TAP5-1040.
-

   Resolution: Fixed
Fix Version/s: 5.2.5
   5.3.0

Applied the patch and updated the unit tests.

> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Assignee: Josh Canfield
>Priority: Minor
> Fix For: 5.3.0, 5.2.5
>
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] Closed: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Josh Canfield (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Josh Canfield closed TAP5-1040.
---


> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Assignee: Josh Canfield
>Priority: Minor
> Fix For: 5.3.0, 5.2.5
>
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




svn commit: r1073129 - in /tapestry/tapestry5/branches/maint-5-2/tapestry-core/src: main/java/org/apache/tapestry5/dom/DTD.java test/java/org/apache/tapestry5/dom/DOMTest.java

2011-02-21 Thread joshcanfield
Author: joshcanfield
Date: Mon Feb 21 20:20:27 2011
New Revision: 1073129

URL: http://svn.apache.org/viewvc?rev=1073129&view=rev
Log:
TAP5-1040 - applied patch and updated tests

Modified:

tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java

tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java?rev=1073129&r1=1073128&r2=1073129&view=diff
==
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
 Mon Feb 21 20:20:27 2011
@@ -52,5 +52,10 @@ public class DTD
 {
 writer.printf("", name, systemId);
 }
+else
+{
+writer.printf("", name);
+}
+
 }
 }

Modified: 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java?rev=1073129&r1=1073128&r2=1073129&view=diff
==
--- 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
 (original)
+++ 
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
 Mon Feb 21 20:20:27 2011
@@ -435,7 +435,7 @@ public class DOMTest extends InternalBas
 Document d = new Document(new XMLMarkupModel());
 d.newRootElement("prime");
 d.dtd("prime", null, null);
-assertEquals(d.toString(), "\n");
+assertEquals(d.toString(), "\n");
 d.dtd("prime", "-//TF", null);
 assertEquals(d.toString(), "\n");
 




svn commit: r1073127 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/dom/DTD.java test/java/org/apache/tapestry5/dom/DOMTest.java

2011-02-21 Thread joshcanfield
Author: joshcanfield
Date: Mon Feb 21 20:12:52 2011
New Revision: 1073127

URL: http://svn.apache.org/viewvc?rev=1073127&view=rev
Log:
TAP5-1040 - integrated patch to allow no system or public id in doctype

Modified:

tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java

tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java?rev=1073127&r1=1073126&r2=1073127&view=diff
==
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DTD.java
 Mon Feb 21 20:12:52 2011
@@ -52,5 +52,9 @@ public class DTD
 {
 writer.printf("", name, systemId);
 }
+else
+{
+writer.printf("", name);
+}
 }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java?rev=1073127&r1=1073126&r2=1073127&view=diff
==
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
 Mon Feb 21 20:12:52 2011
@@ -435,7 +435,7 @@ public class DOMTest extends InternalBas
 Document d = new Document(new XMLMarkupModel());
 d.newRootElement("prime");
 d.dtd("prime", null, null);
-assertEquals(d.toString(), "\n");
+assertEquals(d.toString(), "\n");
 d.dtd("prime", "-//TF", null);
 assertEquals(d.toString(), "\n");
 




[CONF] Apache Tapestry > Ajax and Zones

2011-02-21 Thread confluence







Ajax and Zones
Page edited by Howard M. Lewis Ship


 Changes (2)
 




...
 {code:_javascript_} 
Tapestry.ElementEffect.myeffectname = function(element){ YourJavascriptCodeGoesHere; } }; 
{code}   
h2. Zone Component Id vs. Zone Element Id  Like all Tapestry components, Zones have a component id, specified using the {{t:id}} attribute.  If you do not assign a component id, a unique id is assigned by Tapestry.  However, to coordinate things on the client side, it is necessary for components that wish to update the zone know the _client-side element id_.  This is specified with the {{id}} parameter of the Zone component.  If the {{id}} parameter is not bound, then a unique value (for the current page and render) is generated by Tapestry and this value is difficult to predict. The actual value will be available as the {{clientId}} property of the Zone component itself.  Remember that the component id ({{t:id}}) is used to _inject_ the Zone component into the containing page or component. The client-side id ({{id}}) is used ... on the client side to orchestrate requests and updates.  You will often seen the following construct:  {code:xml}  ...   update {code}   {since:since=5.2} If the Form or Link is enclosed by the Zone itself, then the {{zone}} parameter may be set to the special value {{^}}. The carat is evaluated, on the client side, by searching up form the form or link element for the first enclosing element with the {{t-zone}} CSS class. In this way, the client-side coordination can occur without having to know what the specific client-side id of the Zone is. Because of this, in many cases, it is not longer necessary to specify the Zone's {{id}} parameter. {since}   
h3. Zone Limitations  
...


Full Content


Related Articles


 Page:
 Ajax and Zones





 Page:
 _javascript_





 Page:
 Component Cheat Sheet





 Page:
 Assets





 Page:
 _javascript_ FAQ





 Page:
 Ajax Components FAQ






Tapestry provides easy-to-use support for Ajax, the technique of using _javascript_ to dynamically updating parts of a web page with content from the server without redrawing the whole page. But with Tapestry, you don't have to write any _javascript_ code.

Ajax support is included in many built-in components and component mixins.

Zones

Zones are Tapestry's approach to performing partial page updates. A Zone component renders as an HTML element, typically a , with the "t-zone" CSS class. (It also adds some _javascript_ to the page to "wire up" a Tapestry.ZoneManager object to control updating that element.)

A Zone can be updated via an EventLink or ActionLink component, or by a Form. All of these components support a zone parameter, which provides the id of the Zone's . Clicking such a link will invoke an event handler method on the server as normal ... except that the return value of the event handler method is used to send a partial page response to the client, and the content of that response is used to update the Zone's  in place.

An Update div within a Zone div

In many situations, a Zone is a kind of "wrapper" or "container" for dynamic content; one that provides a look and feel ... a bit of wrapping markup to create a border. In that situation, the Zone  may contain an update .

An Update  is specifically a  element marked with the CSS class "t-zone-update", inside the Zone's .

If an Update div exists within a Zone div, then when Tapestry updates a zone only the update 's content will be changed, rather than the entire Zone .

The show and update functions (see Zone Functions, below) apply to the Zone , not just the update .

Event Handler Return Types

In a traditional request, the return value of an event handler method is used to determine which page will render a complete response, and a redirect is sent to the client to render the ne

[CONF] Apache Tapestry > JavaScript

2011-02-21 Thread confluence







_javascript_
Page edited by Bob Harner


Comment:
Noted $T() as deprecated (because it says so in the tapestry.js file, apparently per HLS 10/10/10 rev 1006321)


 Changes (4)
 




...
It also adds a handful of methods to the Form class, and to Form elements. These are mostly related to input validation and determining element visibility.  
h2. The Tapestry Object $T() 
 
{deprecated:since=5.2 (no replacement)}  
The standard library adds a new function, {{$T()}}. This function is used much like Prototype's {{$()}}, except that instead of returning a DOM object, it returns a hash (an initially empty _javascript_ object) that is associated with the DOM object. This hash is known as _the Tapestry object_.  
...
{code}  
h2. Coming Soon 
 
* Additional Tapestry.ElementEffect functions, plus documentation   
h1. Ajax Components and Mixins  
...


Full Content


Related Articles


 Page:
 _javascript_





 Page:
 Ajax and Zones





 Page:
 Component Cheat Sheet





 Page:
 Assets





 Page:
 _javascript_ FAQ





 Page:
 Ajax Components FAQ






Tapestry includes sophisticated _javascript_ support, based on the Prototype and Scriptaculous libraries. These libraries are all packaged with Tapestry itself ... no extra download is required.

Tapestry will automatically link in prototype.js, scriptaculous.js, effects.js and the Tapestry library, tapestry.js. You can add additional libraries as needed.

Prototype and Scriptaculous Versions




 Tapestry 5.2 
 Prototype 1.6.1 
 Scriptaculous 1.8.2


 Tapestry 5.1 
 Prototype 1.6.0.3 
 Scriptaculous 1.8.2


 Tapestry 5.0 
 Prototype 1.6.0 
 Scriptaculous 1.8.0





Alternatives to Prototype
There are both immediate and long-term efforts underway to allow Tapestry to work better with other _javascript_ libraries, such as JQuery and ExtJS:

	Tapestry5HowToIntegrateJQuery – Using JQuery in addition to Prototype
	Tapestry-Jquery module – Using JQuery in addition to Prototype
	Tapestry5-Jquery module – Using JQuery instead of Prototype
	TAP5-999 proposes an agnostic tapestry.js layer to allow switching from Prototype to JQuery
	TAPS-1364 lists some starting points for ExtJS integration



Changes to Scriptaculous

Tapestry uses a modified version of the main Scriptaculous library, scriptaculous.js, with the library's default autoloading behavior turned off. This lets Tapestry and Tapestry components control which Scriptaculus scripts are loaded, rather than having all of them loaded unnecessarily.

Basic _javascript_

The general strategy in Tapestry is that any significant amount of _javascript_ should be packaged up as a static _javascript_ library, a .js file that can be downloaded to the client.

Page specific _javascript_ should be in the form of minimal statements to initialize objects, referencing the _javascript_ libraries.

Most of this is accomplished via the RenderSupport object.

RenderSupport includes a number of methods that will be used by components, or event by services that are called from components.

addScriptLink()

void addScriptLink(Asset... scriptAssets);

This method adds a link to a script file, a _javascript_ library. A component can inject such a script and pass one or more of assets to this method. Tapestry will ensure that the necessary  elements are added to the top of the document (just inside the  element).

Adding the same asset multiple times does not create duplicate links. The subsequent ones are simply ignored. In this way, each component can add the assets it needs, without worrying about conflicts with other components.

Note that the Prototype, Scriptaculous main and effects libraries, and the standard Tapestry library (which largely consists of support for form input valid

[CONF] Apache Tapestry > Ajax and Zones

2011-02-21 Thread confluence







Ajax and Zones
Page edited by Bob Harner


Comment:
Listed the Tapestry.ElementEffect functions, resolving an old TODO on the _javascript_ page


 Changes (7)
 




...
h2. Zones  
Zones are Tapestry's approach to performing partial page updates. A [Zone component|http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/Zone.html] renders as an HTML element, typically a , with the "t-zone" CSS class. (It also adds some _javascript_ to the page to "wire up" a Tapestry.ZoneManager object to control updating that element.) 
 A Zone can be updated via an EventLink or ActionLink component, or by a Form. All of these components support a zone parameter, which provides the id of the Zone's . Clicking such a link will invoke an event handler method on the server as normal ... except that the return value of the event handler method is used to send a _partial page response_ to the client, and the content of that response is used to update the Zone's  in place. 
...
If an Update div exists within a Zone div, then when Tapestry updates a zone only the update 's content will be changed, rather than the entire Zone .  
The show and update functions (see Zone Functions, below) apply to the Zone , not just the update . 
 h3. Event Handler Return Types 
...
h3. Zone Functions  
A Zone may be initially visible or invisible. When a Zone is updated, it is made visible if not currently so. This is accomplished via a function on the Tapestry.ElementEffect client-side object. By default, the show() function is used for this purpose. The Zone's show parameter is the _name_ of a Tapestry.ElementEffect function. 
A Zone may be initially visible or invisible. When a Zone is updated, it is made visible if not currently so. This is accomplished via a function on the Tapestry.ElementEffect client-side object. By default, the show() function is used for this purpose. If you want Tapestry to call a different Tapestry.ElementEffect function when updates occur, specify its name with the zone's show parameter. 
 
If a Zone is already visible, then a different function is used to highlight the change. Here it is the Zone's update parameter, and a default highlight() function, which performs a yellow fade to highlight that the content of the Zone has changed. 
If a Zone is already visible, then a different effect function is used to highlight the change. By default, the highlight() function is called, which performs a yellow fade to highlight that the content of the Zone has changed. Alternatively, you can specify a different effect function with the Zone's update parameter: 
 
|| Tapestry.ElementEffect Function || Purpose || | show() | make the zone visible if it isn't already visible | | highlight() | Highlight changes to an already-visible zone | | slidedown() | Scroll the content down | | slideup() | Slide the content back up (opposite of slidedown) | | fade() | Fade the content out (opposite of show) |  To have Tapestry update a zone without the usual yellow highlight effect, just specify "show" for the update parameter: {{}}  You may also define and use your own _javascript_ effect function (with lower-case names), like this:  {code:_javascript_} Tapestry.ElementEffect.myeffectname = function(element){ YourJavascriptCodeGoesHere; } {code}   
h3. Zone Limitations  
...


Full Content


Related Articles


 Page:
 _javascript_





 Page:
 Ajax and Zones





 Page:
 Component Cheat Sheet





 Page:
 Assets





 Page:
 _javascript_ FAQ





 Page:
 Ajax Components FAQ






Tapestry provides easy-to-use support for Ajax, the technique of using _javascript_ to dynamically updat

[jira] Assigned: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Josh Canfield (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Josh Canfield reassigned TAP5-1040:
---

Assignee: Josh Canfield

> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Assignee: Josh Canfield
>Priority: Minor
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] Issue Comment Edited: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Bob Harner (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12997434#comment-12997434
 ] 

Bob Harner edited comment on TAP5-1040 at 2/21/11 2:58 PM:
---

Until this patch is applied, as a work-around you can emit the HTML5 doctype 
directly from your page (or layout) class, rather than your template, as 
described at http://tapestry.apache.org/component-templates.html (credit to 
Nille Hammer):

/**
* Output the HTML5 doctype, as a work-around to 
https://issues.apache.org/jira/browse/TAP5-1040
*/
@SetupRender
final void renderDocType(final MarkupWriter writer) {
writer.getDocument().raw("");
}

I checked, and the attached patch still applies cleanly against the trunk and 
seems very low risk.  Does somebody want to apply it?

  was (Author: bobharner):
Until this patch is applied, as a work-around you can emit the HTML5 
doctype directly from your page (or layout) class, rather than your template, 
as described at http://tapestry.apache.org/component-templates.html (credit to 
Nille Hammer):

{code}
/**
* Output the HTML5 doctype, as a work-around to 
https://issues.apache.org/jira/browse/TAP5-1040
*/
@SetupRender
final void renderDocType(final MarkupWriter writer) {
writer.getDocument().raw("");
}
{code}

I checked, and the attached patch still applies cleanly against the trunk and 
seems very low risk.  Does somebody want to apply it?
  
> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Priority: Minor
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] Commented: (TAP5-1040) Allow HTML5 doctype to be printed

2011-02-21 Thread Bob Harner (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12997434#comment-12997434
 ] 

Bob Harner commented on TAP5-1040:
--

Until this patch is applied, as a work-around you can emit the HTML5 doctype 
directly from your page (or layout) class, rather than your template, as 
described at http://tapestry.apache.org/component-templates.html (credit to 
Nille Hammer):

{code}
/**
* Output the HTML5 doctype, as a work-around to 
https://issues.apache.org/jira/browse/TAP5-1040
*/
@SetupRender
final void renderDocType(final MarkupWriter writer) {
writer.getDocument().raw("");
}
{code}

I checked, and the attached patch still applies cleanly against the trunk and 
seems very low risk.  Does somebody want to apply it?

> Allow HTML5 doctype to be printed
> -
>
> Key: TAP5-1040
> URL: https://issues.apache.org/jira/browse/TAP5-1040
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.0, 5.1.0.5
>Reporter: Alexander Kiel
>Priority: Minor
> Attachments: added_ability_to_print_the_HTML5_DOCTYPE.patch
>
>
> According to the HTML5 Working Draft [1], the doctype to be used in the case 
> you are using the HTML syntax is:
>  case-insensitive
> Unfortunately the class org.apache.tapestry5.dom.DTD doesn't allow doctypes 
> with empty public and system identifier. It is also not possible to output 
> the DOCTYPE legacy string , 
> because some parser internal to Tapestry tries to resolve the system 
> identifier. The best thing, I was able to output is the full HTML 4.01 strict 
> doctype:
>  "http://www.w3.org/TR/html4/strict.dtd";>
> It is allowed in HTML5 as obsolete permitted DOCTYPE string, but not desired.
> It would be very simple to allow for what empty HTML5 doctype in 
> org.apache.tapestry5.dom.DTD.
> [1]: http://www.w3.org/TR/2010/WD-html5-20100304/

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira




[CONF] Apache Tapestry > Component Templates

2011-02-21 Thread confluence







Component Templates
Page edited by Bob Harner


Comment:
Added Nille Hammer's work-around for HTML5 doctype


 Changes (3)
 




...
{note}  
For the most part, these templates are standard (X)HTML; HTML/XHTML; Tapestry extensions to ordinary markup are provided in the form of a Tapestry namespace. 
 We'll cover the specific content of templates shortly, first a few details about connecting a component to its template. 
...
As mentioned above, component templates are well-formed XML documents. This means that if you want to use any [HTML entities|http://www.w3.org/TR/html401/sgml/entities.html] (such as \& \  < > ©), you must use an [HTML or XHTML doctype|http://www.w3.org/QA/2002/04/valid-dtd-list.html] in your template. If you choose to use (X)HTML doctypes in your templates, they will be passed on to the client in the resultant (X)HTML. Note that if your pages are composed of multiple components, each with a template, and each template contains a doctype declaration, only the first doctype encountered by the template parser will be passed on to the client.  
It should also be noted that even though *X*HTML DTDs are valid XML DTDs, HTML DTDs aren't valid XML DTDs. This means that HTML doctypes cannot be used by XML parsers. Tapestry works around this limitation internally by using XHTML DTDs to parse templates that use HTML DTDs. This internal mapping is possible because XHTML 1.0 is nothing more than "a reformulation of the three HTML 4 document types as applications of XML 1.0," [as per the W3C|http://www.w3.org/TR/xhtml1/#xhtml]. Don't worry though -- the original HTML 4 doctype will still be emitted to the client\! 
 The following doctypes are the most common (X)HTML doctypes: 
...
{code}  
What about HTML5?  Well, as of version 5.2 Tapestry doesn't yet support the HTML5 doctype directly (see [TAP5-1040|https://issues.apache.org/jira/browse/TAP5-1040]), but there's a partial work-around: just add the following to your page class (or your layout class, if you use one):  {code} /** * Output the HTML5 doctype, as a work-around to https://issues.apache.org/jira/browse/TAP5-1040 */ @SetupRender final void renderDocType(final MarkupWriter writer) { writer.getDocument().raw(""); } {code}  Note that this allows you to use emit HTML5 to the browser, but the problem of [entities not working|https://issues.apache.org/jira/browse/TAP5-840] remains.  
h2. The Tapestry Namespace  
...


Full Content

Component Templates


Related Articles


 Page:
 Templating and Markup FAQ





 Page:
 Component Parameters





 Page:
 Component Libraries





 Page:
 Component Classes





 Page:
 Component Reference




 

Under Tapestry, a component template is the file that contains the markup for that page or component.

Component templates are well formed XML documents. That means that every open tag must have a matching close tag, every attribute must be quoted, and so forth.

At runtime, Tapestry parses the documents and only checks for wellformedness. Even when the document has a DTD or schema, there are no validity checks.

For the most part, these templates are standard HTML/XHTML; Tapestry extensions to ordinary markup are provided in the form of a Tapestry namespace.

We'll cover the specific content of templates shortly, first a few details about connecting a component to its template.

Template Location

Component templates are stored with the component class file. The files have a ".tml" extension (i.e., Tapestry Markup Language), and are stored in the same package as corresponding component class.

Under a typical Maven directory structure, the Java class for a component might be src/main/java/org/example/myapp/components/MyComponent.java. The corresponding template will be src/main/resources/org/example/myapp/components/MyComponent.tml.

Likewise, the Java class for a page might be src/main/java