Skip to content

Instantly share code, notes, and snippets.

@sody
sody / FormFieldSet.java
Last active December 16, 2015 11:09
Form separation in Tapestry
@SupportsInformalParameters
public class FormFieldSet {
@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
private String title;
@Inject
private ComponentResources resources;
@Environmental
@sody
sody / AbstractField.java
Created September 14, 2012 08:27
Tapestry Fixed Control Name Fixin
@SupportsInformalParameters
public abstract class AbstractField implements Field {
@SetupRender
final void setup() {
String id = clientId;
if (formSupport == null)
throw new RuntimeException(String.format("Component %s must be enclosed by a Form component.",
resources.getCompleteId()));
@sody
sody / Deferred.html
Created September 8, 2012 10:50
Tepastry Render Deferred
<t:actionlink t:id="updateLeft" zone="prop:leftZoneId"
rel="tooltip" title="zone=${prop:leftZoneId}" class="btn">
${message:label.update}
</t:actionlink>
<br/><br/>
<t:zone t:id="leftZone">
<div class="hero-unit">
<p>${message:message.help-text}</p>
<p>${leftContent}</p>
</div>
@sody
sody / Module.java
Created August 1, 2012 13:57
MetaDataLocator Usage
public static void contributeMetaWorker(MappedConfiguration<Class, MetaDataExtractor> configuration) {
// register meta extractor for @RequireSession annotation
configuration.addInstance(RequireSession.class, RequireSessionExtractor.class);
}
@sody
sody / AjaxUpload.java
Created July 6, 2012 11:31
Tapestry Ajax Upload Fixin
package com.example.ui.mixins;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BindParameter;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
@sody
sody / step3.sh
Created July 3, 2012 23:19
Heroku Migration
$ heroku login
$ heroku create <app-name>
@sody
sody / PreventDoubleSubmit.java
Created June 29, 2012 16:33
Prevent Double Submit
package com.example.ui.mixins;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;
/**
* This class represents fixin for form component that adds client-side logic to page that prevents double form
@sody
sody / GoogleApi.java
Created January 20, 2012 14:05
Custom OAuth API with SpringSocial. Google OAuth2.
public interface Google extends ApiBinding {
String API_URL_BASE = "https://www.googleapis.com/oauth2/v2/";
UserOperations userOperations();
}
public interface UserOperations {
GoogleProfile getUserProfile();
@sody
sody / Authority.java
Created January 12, 2012 12:46
Secure pages with tapestry5. Rethinking
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Authority {
/**
* Defines authority needed to access the page or action.
*/
String value();
}
@sody
sody / FacebookConnect.java
Created October 29, 2011 14:58
spring-social and tapestry5
package com.example.components;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.Cached;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.RequestParameter;