This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2011 Marko Lavikainen | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.Locale; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import org.apache.commons.lang.StringEscapeUtils; | |
import org.apache.commons.lang.StringUtils; | |
import org.dom4j.Attribute; | |
import org.dom4j.Document; | |
import org.dom4j.Element; | |
import org.dom4j.Text; | |
public class JsTemplateProcessor { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MathQuestion extends Component { | |
@Element | |
private SimpleLabel answer = new SimpleLabel(); | |
enum Operation { | |
ADDITION("+") { | |
@Override | |
public long calculate(long val1, long val2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE. This example is extremely simplified and shows only the idea. | |
public interface AuthService { | |
boolean login(String username, String password); | |
/** | |
* 1. Generates random key | |
* 2. Sends key to given email if it was registered | |
* 3. Returns the generated key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Chat extends Component implements ChatServiceClient { | |
@Inject | |
private ChatService service; | |
private long lastAccess = -1; | |
@Element | |
public List<ChatMsg> messages() { | |
return service.getMessages(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Chart extends Component { | |
@Attribute | |
private String key1 = "Example 1"; | |
@Attribute | |
private String key2 = "Example 2"; | |
@Attribute | |
private int value1 = 100; | |
@Attribute | |
private int value2 = 200; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EchoWriter extends Component { | |
@Inject | |
@Element | |
private SimpleLabel echo; | |
@ScriptElement(onUpdate=false) | |
public JsInit jsInit() { | |
return new JsInit(this); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Struct { | |
<T> T get(FieldType<T> type); | |
<T> void set(FieldType<T> type, T value); | |
} | |
/////////////////////////////////////// | |
public interface FieldType<T> { | |
String getFieldName(); | |
Class<T> getType(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.MultiMap | |
import java.net.URLEncoder | |
import scala.collection.mutable.{HashMap, StringBuilder, HashSet} | |
import scala.collection.mutable.StringBuilder; | |
class LinkBuilder(path : String) { | |
private var attributes = new collection.mutable.HashMap[String, collection.mutable.Set[String]]() with collection.mutable.MultiMap[String, String]; | |
override def toString() : String = { |