Skip to content

Instantly share code, notes, and snippets.

@uklance
uklance / Tab.java
Last active December 11, 2015 22:58
TabGroup tapestry component for use with twitter-bootstrap CSS.
package mypackage.components;
import javax.inject.Inject;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.services.Request;
import mypackage.TabModel;
@uklance
uklance / AppModule.java
Last active December 17, 2015 08:49
Create a hibernate / lucene FullTextSession service that can be @Inject'ed into your tapestry pages and services
@Scope(ScopeConstants.PERTHREAD)
public static FullTextSession buildFullTextSession(PropertyShadowBuilder propertyShadowBuilder) {
return Search.getFullTextSession(sessionManager.getSession());
}
@uklance
uklance / LazyTreeModel.java
Last active December 18, 2015 14:18
A more database friendly TreeModel implementation
public class LazyTreeModel<T> implements TreeModel<T> {
private final ValueEncoder<T> encoder;
private final LazyTreeModelSource<T> source;
public LazyTreeModel<T>(ValueEncoder<T> encoder, LazyTreeModelSource<T> source) {
this.encoder = encoder;
this.source = source;
}
@Override
@Property
private Country country;
@Property
private City city;
public Country[] getCountries() {
return new Country[] { ... };
}
<!-- page.tml -->
<t:grid source="myCustomGridDataSource" ... />
// Page.java
public GridDataSource getMyCustomGridDataSource() {
final List<Document> docs = documentDAO.getAll();
GridDataSource wrapper = new CollectionGridDataSource(docs) {
public int getAvailableRows() {
return super.getAvailableRows() + 1;
}
207.61.224.54 - - [06/Jan/2014:05:44:15 +0000] "GET / HTTP/1.1" 200 606 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/6.1.1 Safari/537.73.11"
207.61.224.54 - - [06/Jan/2014:05:44:16 +0000] "GET /assets/1.0-SNAPSHOT/tapestry/default.css HTTP/1.1" 200 2089 "http://tapestry-atmosphere.uklance.cloudbees.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/6.1.1 Safari/537.73.11"
207.61.224.54 - - [06/Jan/2014:05:44:16 +0000] "GET /assets/1.0-SNAPSHOT/ctx/bootstrap/css/bootstrap.css HTTP/1.1" 200 17911 "http://tapestry-atmosphere.uklance.cloudbees.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/6.1.1 Safari/537.73.11"
207.61.224.54 - - [06/Jan/2014:05:44:34 +0000] "GET /chatdemo;jsessionid=a5g6txxdf2uo10detrcbjztn HTTP/1.1" 200 3000 "http://tapestry-atmosphere.uklance.cloudbees.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.73.11 (
public class ConverterGridDataSource implements GridDataSource {
private final GridDataSource delegate;
private final Converter converter;
public ConverterGridDataSource(GridDataSource delegate, Converter converter) {
this.delegate = delegate;
this.converter = converter;
}
public int getAvailableRows() {
@uklance
uklance / RunNotifierJUnit4ClassRunner.java
Created April 2, 2014 07:51
BlockJUnit4ClassRunner events
package sandbox.junit;
import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
import org.junit.runner.notification.StoppedByUserException;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.InitializationError;
@uklance
uklance / AppModule.java
Last active August 29, 2015 14:01
Tapestry: Custom BeanModel to support "is" getters for javal.ang.Boolean
public class AppModule {
public static BeanModelSource decorateBeanModelSource(BeanModelSource defaultImpl) {
return new MyBeanModelSource(defaultImpl);
}
}