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
| class FluentELResolver extends BeanELResolver { | |
| public boolean isReadOnly(ELContext context, Object base, Object property) { | |
| if (base == null || !(property instanceof String)) { | |
| return true; | |
| } | |
| Method method = getFluentMethod(context, base, property.toString()); | |
| if (method == null) { | |
| return true; | |
| } |
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
| <faces-config> | |
| xmlns="http://java.sun.com/xml/ns/javaee" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" | |
| version="2.0"> | |
| <application> | |
| <el-resolver> | |
| de.openknowledge.extensions.el.FluentELResolver | |
| </el-resolver> | |
| </application> |
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 DateAdapter extends XmlAdapter<String, XMLGregorianCalendar> { | |
| @Override | |
| public XMLGregorianCalendar unmarshal(String value) throws Exception { | |
| ... | |
| } | |
| @Override | |
| public String marshal(XMLGregorianCalendar value) throws Exception { | |
| ... |
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
| @XmlJavaTypeAdapter(DateAdapter.class) | |
| protected XMLGregorianCalendar dateOfBirth; |
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
| private static SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"); | |
| ... | |
| @Override | |
| public XMLGregorianCalendar unmarshal(String value)throws Exception { | |
| ... | |
| Date date=format.parse(value); | |
| GregorianCalendar calendar=new GregorianCalendar(); |
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
| // Das Attribut 'format' wird als 'ThreadLocal' definiert: | |
| private static ThreadLocal<SimpleDateFormat> format = new ThreadLocal<SimpleDateFormat>(); | |
| // Beim ersten Zugriff innerhalb eines Threads wird das Objekt initialisiert | |
| private SimpleDateFormat getFormat() { | |
| if (format.get() == null) { | |
| format.set(new SimpleDateFormat("yyyy-MM-dd")); | |
| } | |
| return format.get(); | |
| } |
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
| private BigDecimal processNumberInput(String numberString) | |
| throws ParseException { | |
| Number number = numFormatGerman.parse(numberString); | |
| ... | |
| String internalAmountString = numFormatEnglish.format(number); | |
| ... | |
| return new BigDecimal(internalAmountString); | |
| } |
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
| var messageReceived = function(event) { | |
| var eventData = event.data.toString(); | |
| console.log("Received via socket: "+eventData); | |
| }; | |
| var socket = new WebSocket("ws://www.example.com/mywebsocketapp/myspecializedsocket/do.connect"); | |
| socket.onmessage = messageReceived; | |
| //send text to server | |
| socket.send("testtext"); |
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 MyWebSocketApplication extends WebSocketApplication { | |
| public boolean isApplicationRequest(Request request) { | |
| // determine if this application is responsible for this websocket request (identification by incoming request) | |
| return request.toString().contains("/mywebsocketapp/myspecializedsocket/do.connect"); | |
| } | |
| public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) { | |
| // create a new WebSocket and add it to the list of Sockets hold by this app | |
| WebSocket socket = new MyWebSocket(protocolHandler, listeners); |
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
| Map<String, Object> requestDataStore = new HashMap<String, Object>(); | |
| boundRequestContext.associate(requestDataStore); | |
| boundRequestContext.activate(); | |
| useRequestScopeInHere(); | |
| try { | |
| boundRequestContext.invalidate(); | |
| boundRequestContext.deactivate(); | |
| } finally { | |
| boundRequestContext.dissociate(requestDataStore); | |
| } |