Yes, it is expected that developers will create their own components, and this is pretty easy to do. There are many projects where people create their component libraries. If you want to see some examples, check out:
. .tml .java. .java src, (src/main/java/com/examples/app/components), .tml , (src/main/resources/com/examples//)
, Facebook, EventInfo Event, URL-, Facebook.
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.persistence.Transient;
import net.xeric.register.entities.Event;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.PageRenderLinkSource;
public class ShareEventOnFacebook {
@Inject
private PageRenderLinkSource linkSource;
@Parameter(required=true)
@Property
private Event event;
public String getFacebookShareURL() {
Link link = linkSource.createPageRenderLinkWithContext("EventInfo", event);
String linkURL = "";
try {
linkURL = URLEncoder.encode(link.toAbsoluteURI(),"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return linkURL;
}
public String getFacebookShareTitle() {
String returnValue = "";
try {
returnValue = URLEncoder.encode(event.getDescription(), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
}
, Event , . , , <t:shareeventonfacebook event="myEvent"/>
:
<t:container
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<a href="http://www.facebook.com/sharer.php?u=${facebookShareURL}">
Share on Facebook
</a><br/>
</t:container>
, :
<t:shareeventonfacebook event="event"/>