001 /*
002 * Apache License
003 * Version 2.0, January 2004
004 * http://www.apache.org/licenses/
005 *
006 * Copyright 2008-2010 by chenillekit.org
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 */
014
015 package org.chenillekit.tapestry.core.mixins;
016
017 import org.apache.tapestry5.BindingConstants;
018 import org.apache.tapestry5.ClientElement;
019 import org.apache.tapestry5.MarkupWriter;
020 import org.apache.tapestry5.annotations.Environmental;
021 import org.apache.tapestry5.annotations.Import;
022 import org.apache.tapestry5.annotations.InjectContainer;
023 import org.apache.tapestry5.annotations.Parameter;
024 import org.apache.tapestry5.dom.Element;
025 import org.apache.tapestry5.services.javascript.JavaScriptSupport;
026
027 /**
028 * @version $Id: NiftyCube.java 674 2010-07-29 12:47:25Z homburgs $
029 */
030 @Import(library = {"niftycube.js"}, stylesheet = {"niftyCorners.css"})
031 public class NiftyCube
032 {
033 /**
034 * let you allow to restrict the direction of resizing.
035 * 'vertical', 'horizontal' or empty for both
036 */
037 @Parameter(required = false, defaultPrefix = BindingConstants.LITERAL, value = "normal")
038 private String options;
039
040 /**
041 * RenderSupport to get unique client side id.
042 */
043 @Environmental
044 private JavaScriptSupport javascriptSupport;
045
046 /**
047 * The field component to which this mixin is attached.
048 */
049 @InjectContainer
050 private ClientElement clientElement;
051
052 /**
053 * Tapestry render phase method. End a tag here.
054 *
055 * @param writer the markup writer
056 */
057 void afterRender(MarkupWriter writer)
058 {
059 Element element = writer.getDocument().getElementById(clientElement.getClientId());
060 javascriptSupport.addScript("Nifty('%s#%s','%s');", element.getName(), clientElement.getClientId(), options);
061 }
062 }