empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r683198 [4/8] - in /incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext: ./ .settings/ src/ src/META-INF/ src/org/ src/org/apache/ src/org/apache/empire/ src/org/apache/empire/struts2/ src/org/apache/empire/struts2/action/ src/org/apac...
Date Wed, 06 Aug 2008 09:34:45 GMT
Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlTagDictionary.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlTagDictionary.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlTagDictionary.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlTagDictionary.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,157 @@
+package org.apache.empire.struts2.html;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class HtmlTagDictionary
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(HtmlTagDictionary.class);
+
+    private static HtmlTagDictionary htmlDictonary; 
+    
+    public static HtmlTagDictionary getInstance()
+    {
+        if (htmlDictonary==null)
+        {
+            log.warn("HtmlTagDictionary has not been set. Using Default Dictionary");
+            htmlDictonary = new DefaultHtmlTagDictionary();
+        }    
+        return htmlDictonary;
+    }
+
+    public static void set(HtmlTagDictionary htmlDictionay)
+    {
+        htmlDictonary = htmlDictionay;
+    }
+    
+    // ------- Misc -------
+    public abstract String FloatClear(); // Complete FloatClearTag expresseion (e.g. <div style="clear:both;"></div>)
+
+    // ------- Flexible Tag -------   
+    public static class FlexDivRenderInfo
+    {
+        public String tag;
+        public String attributes;
+        public String bodyBegin;
+        public String bodyEnd;
+        // Konstruktor
+        public FlexDivRenderInfo(String tag, String attributes, String bodyBegin, String bodyEnd)
+        {
+            this.tag = tag;
+            this.attributes = attributes;
+            this.bodyBegin = bodyBegin;
+            this.bodyEnd = bodyEnd; 
+        }
+    }
+    public abstract FlexDivRenderInfo FlexDivTag(String type, String userAgent);
+    
+    // ------- Form -------
+    public abstract String FormDefaultOnSubmitScript();
+    public abstract boolean FormDefaultRenderWrapper();
+    public abstract String FormPartWrapperTag();
+    public abstract String FormPartWrapperClass();
+    public abstract String FormPartWrapperAttributes();
+    
+    // ------- Input Control -------
+    public abstract boolean InputReadOnlyAsData(); // default is false
+    public abstract int     InputMaxCharSize(); // maximum number or characters in size (e.g. 40)
+    public abstract String InputWrapperTag();
+    public abstract String InputWrapperBody();  // e.g. "<div class=\"clearBoth\"><!-- ? --></div>" 
+    public abstract String InputLabelTag();
+    public abstract String InputRequiredTag();
+    public abstract String InputControlTag();
+
+    public abstract String InputWrapperClass();
+    public abstract String InputLabelClass();
+    public abstract String InputRequiredClass();
+    public abstract String InputControlClass();
+    public abstract String InputReadOnlyClass();
+    public abstract String InputReadOnlyDataWrapperTag();
+
+    // ------- Anchor -------
+    public abstract String AnchorDisabledTag();
+    public abstract String AnchorDisabledClass();
+
+    // ------- Button -------
+    public abstract String ButtonTag();
+    public abstract String ButtonClass();
+    public abstract String ButtonSameActionDefaultOnClickScript();
+    public abstract String ButtonOtherActionDefaultOnClickScript();
+
+    // ------- Submit Button -------
+    public abstract String SubmitClass();
+    public abstract String SubmitControlTag();  // only valid if embed=true and InputWrapperTag != null
+    public abstract String SubmitControlClass();
+    public abstract String SubmitControlAttributes();
+    
+    // ------- Menu Tags -------
+    public abstract String MenuTag();
+    public abstract String MenuItemTag();
+    public abstract String MenuItemLinkClass();
+    public abstract String MenuItemLinkDefaultOnClickScript();
+    public abstract String MenuItemCurrentClass(); 
+    public abstract String MenuItemDisabledClass();
+    public abstract String MenuItemExpandedClass();
+    
+    // ------- TableHead -------
+    public abstract String TableHeadRowTag();   // "tr"
+    public abstract String TableHeadColumnTag(); // "th"
+    public abstract String TableHeadColumnLinkEnabledClass();
+    public abstract String TableHeadColumnLinkDisabledClass();
+    public abstract String TableHeadColumnLinkCurrentClass();
+    public abstract String TableHeadColumnLinkCurrentAscendingClass();
+    public abstract String TableHeadColumnLinkCurrentDescendingClass();
+    public abstract String TableHeadSortAscendingIndicator();  // "[a]"
+    public abstract String TableHeadSortDescendingIndicator(); // "[d]"
+    public abstract String TableHeadSelectColumnIndicator(); // [X]
+    public abstract String TableHeadSelectAscendingIndicator(); // [a]
+    public abstract String TableHeadSelectDescendingIndicator(); // [d]
+    public abstract String TableHeadLinkDefaultOnClickScript();
+    
+    // ------- Pager -------
+    public abstract String PagerTag();
+    public abstract String PagerClass();
+    public abstract String PagerPageTag();
+    public abstract String PagerPageClass();
+    public abstract String PagerLinkClass();
+    public abstract String PagerLabelTag();
+    public abstract String PagerLabelClass();
+    public abstract String PagerLabelText();
+    public abstract String PagerPaddingText();
+    public abstract String PagerLinkDefaultOnClickScript();
+    
+    public abstract String PagerFirstPageText();
+    public abstract String PagerRewindText();
+    public abstract String PagerForwardText();
+    public abstract String PagerLastPageText();
+    public abstract String PagerFirstPageTextDisabled();
+    public abstract String PagerRewindTextDisabled();
+    public abstract String PagerForwardTextDisabled();
+    public abstract String PagerLastPageTextDisabled();
+
+    // ------- PageInfo -------
+
+    public abstract String PageInfoTag();
+    public abstract String PageInfoClass();
+    public abstract String PageInfoItemTag();
+    public abstract String PageInfoLabel();
+    public abstract String PageInfoLabelTo();
+    public abstract String PageInfoLabelOf();
+    public abstract String PageInfoLabelPadding();
+
+    // ------- Errors -------
+
+    public abstract String ErrorListTag();
+    public abstract String ErrorListClass();
+    public abstract String ErrorEntryTag();
+    public abstract String ErrorItemEntryClass();
+    public abstract String ErrorActionEntryClass();
+    public abstract String ErrorEntryWrapperTag();
+
+    // ------- Message -------
+
+    public abstract String MessageTag();
+    public abstract String MessageClass();
+    
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlWriter.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlWriter.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/HtmlWriter.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,222 @@
+package org.apache.empire.struts2.html;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.StringUtils;
+import org.apache.struts2.views.util.TextUtil;
+
+
+public class HtmlWriter
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(HtmlWriter.class);
+    
+    public static class HtmlTag
+    {
+        private HtmlWriter w;
+        private String name;
+        private boolean hasBody;
+        
+        protected HtmlTag(HtmlWriter writer, String name, boolean hasBody)
+        {
+            this.w = writer;
+            this.name = name;
+            this.hasBody = hasBody;
+        }
+        
+        protected void startTag()
+        {
+            // write start
+            if (name!=null)
+            {
+                w.print("<");
+                w.print(name);
+            }
+        }
+        
+        public boolean isValid()
+        {
+            return (w!=null && name!=null);
+        }
+
+        public void addAttributes(String attributes)
+        {
+            if (name==null || attributes==null)
+                return; // Ignore Attributes with null values
+            w.print(" ");
+            w.print(attributes);
+        }
+        
+        public void addAttributeNoCheck(String attrib, Object value, boolean escapeHtml)
+        {
+            if (name==null)
+                return;
+            // Get String value
+            String strValue = StringUtils.valueOf(value);
+            if (escapeHtml)
+                strValue = TextUtil.escapeHTML(strValue);
+            // Add Attribute
+            w.print(" ");
+            w.print(attrib);
+            w.print("=\"");
+            w.print(strValue);
+            w.print("\"");
+        }
+        
+        public void addAttribute(String attrib, Object value, boolean escapeHtml)
+        {
+            if (name==null || value==null)
+                return; // Ignore Attributes with null values
+            String strValue = value.toString();
+            if (strValue==null || strValue.length()==0)
+                return; // Ingore Emtpy Strings
+            if (escapeHtml)
+                strValue = TextUtil.escapeHTML(strValue);
+            w.print(" ");
+            w.print(attrib);
+            w.print("=\"");
+            w.print(strValue);
+            w.print("\"");
+        }
+
+        public void addAttribute(String attrib, Object value)
+        {
+            addAttribute(attrib, value, false);
+        }
+        
+        public void addAttribute(String attrib)
+        {
+            addAttribute(attrib, attrib, false);
+        }
+
+        public void addAttribute(String attrib, boolean present)
+        {
+            if (present)
+                addAttribute(attrib, attrib, false);
+        }
+
+        public void beginBody(String body, boolean newLine)
+        {
+            if (name!=null)
+                w.print(">", newLine);
+            if (body!=null)
+                w.print(body);
+            hasBody = true;
+        }
+        
+        public void beginBody(String body)
+        {
+            beginBody(body, false);
+        }
+        
+        public void beginBody(boolean newLine)
+        {
+            beginBody(null, newLine);
+        }
+        
+        public void beginBody()
+        {
+            beginBody(null, false);
+        }
+        
+        public void endTag(String body, boolean newLine)
+        {
+            // Write body
+            if (body!=null && body.length()>0)
+            {
+                if (hasBody==false)
+                    beginBody(body, false);
+                else w.print(body);
+            }
+            // End of Tag
+            if (name!=null)
+            {
+                // Check Body
+                if (hasBody)
+                {
+                    w.print("</");
+                    w.print(name);
+                    w.print(">", newLine);
+                }
+                else
+                {   
+                    w.print(" />", newLine);
+                }
+            }
+            // done
+            w = null;
+        }
+
+        public void endTag(String body)
+        {
+            endTag(body, false);
+        }
+
+        public void endTag(boolean newLine)
+        {
+            endTag(null, newLine);
+        }
+
+        public void endTag()
+        {
+            endTag(null, false);
+        }
+    }   
+    
+    private Writer writer;
+    
+    public HtmlWriter(Writer writer)
+    {
+        this.writer = writer;
+    }
+
+    private void print(String text, boolean endOfLine)
+    {
+        try {
+            // Check Param
+            if (text==null)
+            {
+                log.warn("cannot print text value of null!");
+                return; // nothing do do
+            }
+            // Print now
+            writer.write(text);
+            if (endOfLine)
+                writer.write("\n");
+          } catch(IOException e) {
+              log.error(e.getMessage());
+              log.error(e.getStackTrace());
+          }
+    }
+
+    public void print(String text)
+    {
+        print(text, false);
+    }
+
+    public void println(String text)
+    {
+        print(text, true);
+    }
+
+    public void println()
+    {
+        print("", true);
+    }
+    
+    public HtmlTag startTag(String name)
+    {
+        HtmlTag tag = new HtmlTag(this, name, false);
+        tag.startTag();
+        return tag;
+    }
+    
+    public HtmlTag continueTag(String name, boolean hasBody)
+    {
+        return new HtmlTag(this, name, hasBody);
+    }
+    
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/package.html?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/package.html (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/html/package.html Wed Aug  6 02:34:41 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionAccessInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionAccessInterceptor.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionAccessInterceptor.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionAccessInterceptor.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,64 @@
+package org.apache.empire.struts2.interceptors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.action.ActionAccessValidator;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionProxy;
+
+
+@SuppressWarnings("serial")
+public class ActionAccessInterceptor extends InterceptorSupport
+{
+    // Logger
+    @SuppressWarnings("hiding")
+    protected static Log log = LogFactory.getLog(ActionAccessInterceptor.class);
+
+    private String loginAction = null;
+    
+    private String accessDeniedAction = null;
+    
+    public void setLoginAction(String loginAction)
+    {
+        this.loginAction = loginAction;
+    }
+
+    public void setAccessDeniedAction(String accessDeniedAction)
+    {
+        this.accessDeniedAction = accessDeniedAction;
+    }
+
+    @Override
+    public String intercept(ActionInvocation invocation) throws Exception
+    {
+        // Set the action object to the HttpRequest
+        Object action = invocation.getAction();
+        // Check Login
+        if (action instanceof ActionAccessValidator)         
+        {
+            // Check wether login is required
+            if (loginAction!=null && ((ActionAccessValidator)action).loginRequired())
+            {   // Log Info
+                if (log.isWarnEnabled())
+                    log.warn("Access to action " + action.getClass().getName() + " requires user login. Redirecting to " + loginAction);
+                // redirect to login page
+                return redirect(loginAction, true); 
+            }
+            // Check user has access to the action and the desired method
+            if (accessDeniedAction!=null)
+            {
+                ActionProxy proxy = invocation.getProxy();
+                if (((ActionAccessValidator)action).hasAccess(proxy.getMethod())==false)
+                {   // Log Info
+                    if (log.isWarnEnabled())
+                        log.warn("Access to action " + action.getClass().getName() + " method " + proxy.getMethod() + " has been denied. Redirecting to " + accessDeniedAction);
+                    // redirect to Access Denied page
+                    return redirect(accessDeniedAction, true); 
+                }
+            }
+        }
+        // Call base
+        return invocation.invoke();
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionBasicsInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionBasicsInterceptor.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionBasicsInterceptor.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/ActionBasicsInterceptor.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,62 @@
+/*
+ * ESTEAM Software GmbH, 13.07.2007
+ */
+package org.apache.empire.struts2.interceptors;
+
+import org.apache.empire.struts2.action.Disposable;
+import org.apache.empire.struts2.action.ExceptionAware;
+import org.apache.struts2.ServletActionContext;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ActionProxy;
+
+
+@SuppressWarnings("serial")
+public class ActionBasicsInterceptor extends InterceptorSupport
+{
+    private String errorAction = null;
+
+    public void setErrorAction(String errorAction)
+    {
+        this.errorAction = errorAction;
+    }
+
+    @Override
+    public String intercept(ActionInvocation invocation) throws Exception
+    {
+        // Set the action object to the HttpRequest
+        Object action = invocation.getAction();
+        // Call base
+        try {
+            // Log Info
+            if (log.isInfoEnabled())
+                log.info("Processing action " + action.getClass().getName() + " for uri= " + ServletActionContext.getRequest().getRequestURI());
+            // Store action on Request
+            ServletActionContext.getRequest().setAttribute("action", action);
+            // Check Disposible interface and call init
+            if (action instanceof Disposable)         
+            {
+               ((Disposable)action).init(); 
+            }
+            // Invoke Action
+            return invocation.invoke();
+            
+        } catch (Exception e) {
+            // catch everything here and forward exception
+            ActionProxy proxy = invocation.getProxy();
+            log.error("An exception occurred while processing the action " + proxy.getActionName() + "!" + proxy.getMethod(), e);
+            if (action instanceof ExceptionAware)
+            {   // Let action handle it
+                String result = ((ExceptionAware)action).handleException(e, proxy.getMethod());
+                if (result!=null && result.length()>0)
+                    return result;
+            }
+            // redirect
+            if (errorAction!=null && errorAction.length()>0)
+                return redirect(errorAction, true);
+            // Forward the action
+            throw(e); 
+        }
+    }
+
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/InterceptorSupport.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/InterceptorSupport.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/InterceptorSupport.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/InterceptorSupport.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,60 @@
+/*
+ * ESTEAM Software GmbH, 13.07.2007
+ */
+package org.apache.empire.struts2.interceptors;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.views.util.UrlHelper;
+
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
+
+public abstract class InterceptorSupport extends AbstractInterceptor
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(InterceptorSupport.class);
+    
+    public static final String NONE = "none";
+    
+    protected String redirect(String target, boolean appendSourceUri)
+        throws IOException
+    {   
+        HttpServletRequest req = ServletActionContext.getRequest();
+        // Create rediect URL
+        StringBuffer url = new StringBuffer();
+        if (target.indexOf('/')<0)
+        {
+            url.append(req.getContextPath());
+            url.append('/');
+        }
+        // The Target
+        url.append(target);
+        // Add .action
+        if (target.indexOf('?')<0 && target.indexOf('.')<0)
+        {
+            url.append(".action");
+        }
+        // Apppend URI
+        if (appendSourceUri)
+        {   
+            url.append(target.indexOf('?')<0 ? '?' : '&');
+            url.append( "source-uri=" );
+            url.append( UrlHelper.translateAndEncode(req.getRequestURI()) ); 
+        }
+        // Log Info
+        if (log.isInfoEnabled())
+            log.info("Redirecting request from " + req.getRequestURI() + " to " + url.toString());
+        // Redirect
+        HttpServletResponse response = ServletActionContext.getResponse();
+        String redirectURL = response.encodeRedirectURL(url.toString());
+        response.sendRedirect( redirectURL );
+        return NONE; 
+    }
+
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/package.html?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/package.html (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/interceptors/package.html Wed Aug  6 02:34:41 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/AnchorComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/AnchorComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/AnchorComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/AnchorComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,132 @@
+package org.apache.empire.struts2.jsp.components;
+
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.html.HtmlTagDictionary;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+import org.apache.struts2.components.Anchor;
+
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public class AnchorComponent extends Anchor
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(AnchorComponent.class);
+    
+    private String  action;
+    private String  text;
+    private boolean disabled = false;
+    private String  disabledTag = null;
+
+    public AnchorComponent(ValueStack stack, HttpServletRequest req, HttpServletResponse res)
+    {
+        super(stack, req, res);
+    }
+    
+    public String getUrl(String actionName)
+    {
+        String namespace = null;
+        String method = null;
+        String scheme = null;
+        boolean includeContext = true;
+        boolean encodeResult = true;
+        return this.determineActionURL(actionName, namespace, method, request, response, parameters, scheme, includeContext, encodeResult);
+    }
+    
+    @Override
+    public boolean usesBody()
+    {
+        // super.usesBody();
+        return true; 
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public boolean start(Writer writer)
+    {
+        // return super.start(writer);
+        // evaluateParams(); // We need to call this!
+        return true;
+    }
+
+    @Override
+    public boolean end(Writer writer, String body)
+    {
+        // return super.end(writer, body);
+        try {
+
+            // Check writer
+            if (writer==null)
+                return false;
+           
+            // HtmlTagDictionary dic = HtmlTagDictionary.getInstance();  
+            HtmlWriter htmlWriter = new HtmlWriter(writer);
+
+            // The Anchors
+            if (disabled==false)
+            {
+                String url = getUrl(action);
+
+                HtmlTag a = htmlWriter.startTag("a");
+                a.addAttribute("id",       this.getId());
+                a.addAttribute("href",     url);
+                a.addAttribute("target",   this.targets);
+                a.addAttribute("class",    this.cssClass);
+                a.addAttribute("style",    this.cssStyle);
+                a.addAttribute("onclick",  this.onclick);
+                a.beginBody(text);
+                a.endTag(body);
+            }
+            else
+            {   
+                // disabledTag = null
+                HtmlTagDictionary dic = HtmlTagDictionary.getInstance();
+                if (disabledTag == null)
+                    disabledTag = dic.AnchorDisabledTag();
+                if (cssClass ==null)
+                    cssClass = dic.AnchorDisabledClass(); 
+                // The value
+                HtmlTag s = htmlWriter.startTag(disabledTag);
+                s.addAttribute("class",    this.cssClass);
+                s.addAttribute("style",    this.cssStyle);
+                s.beginBody(text);
+                s.endTag(body);
+            }
+            return false;
+            
+        } catch (Exception e) {
+            log.error("error when rendering", e);
+            return false;
+        }
+        finally {
+            popComponentStack();
+        }
+    }
+    
+    public void setAction(String action)
+    {
+        this.action = action;
+    }
+
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+
+    public void setDisabled(boolean disabled)
+    {
+        this.disabled = disabled;
+    }
+
+    public void setDisabledTag(String disabledTag)
+    {
+        this.disabledTag = disabledTag;
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/CalendarComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/CalendarComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/CalendarComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/CalendarComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,338 @@
+/*
+ * ESTEAM Software GmbH, 17.08.2007
+ */
+package org.apache.empire.struts2.jsp.components;
+
+import java.io.Writer;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.Attributes;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+import org.apache.empire.struts2.jsp.components.info.CalendarInfo;
+import org.apache.empire.struts2.jsp.components.info.CalendarInfo.CalendarDayInfo;
+import org.apache.struts2.components.UIBean;
+
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public class CalendarComponent extends UIBean
+{
+    // Logger
+    protected static Log log                 = LogFactory.getLog(ControlComponent.class);
+
+    private CalendarInfo calendarInfo        = null;
+    private String       selectDateAction    = null;
+    private String       selectWeekdayAction = null;
+    private String       selectWeekAction    = null;
+    private String       selectMonthAction   = null;
+    private String       cellpadding         = null;
+    private String       cellspacing         = null;
+    private String       monthClass;
+    private String       dayOfWeekClass;
+    private String       weekOfYearClass;
+    private String       dateEmptyClass;
+    private String       dateValidClass;
+    private String       dateLinkClass;
+    private String       dateTodayClass;
+    private String       dateSelectedClass;
+    private String       paramName           = "item";
+
+    public CalendarComponent(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
+    {
+        super(stack, request, response);
+    }
+
+    @Override
+    protected String getDefaultTemplate()
+    {
+        return null;
+    }
+
+    @Override
+    public boolean start(Writer writer)
+    {
+        return super.start(writer);
+    }
+
+    @Override
+    public final boolean end(Writer writer, String body)
+    {
+        // evaluateParams();
+        try
+        { // No Value
+
+            // Render value
+            HtmlWriter htmlWriter = new HtmlWriter(writer);
+            HtmlTag table = htmlWriter.startTag("table");
+            table.addAttribute("id", this.id);
+            table.addAttribute("class", this.cssClass);
+            table.addAttribute("style", this.cssStyle);
+            table.addAttribute("cellpadding", this.cellpadding);
+            table.addAttribute("cellspacing", this.cellspacing);
+            table.beginBody();
+
+            renderHeader(htmlWriter);
+            renderBody(htmlWriter);
+
+            table.endTag();
+            return false; // do not evaluate body again!
+
+        } catch (Exception e)
+        {
+            log.error("error when rendering", e);
+            return false; // do not evaluate body again!
+        } finally
+        {
+            popComponentStack();
+        }
+    }
+
+    private void renderHeader(HtmlWriter writer)
+    {
+        HtmlTag monthHeader = writer.startTag("tr");
+        monthHeader.beginBody();
+
+        HtmlTag thMonth = writer.startTag("th");
+        thMonth.addAttribute("class", this.monthClass);
+        thMonth.addAttribute("colspan", 8);
+        thMonth.beginBody();
+        String item = calendarInfo.getLinkText();
+        String text = calendarInfo.getMonthText() + " " + calendarInfo.getYearText();
+        if (selectMonthAction != null)
+        {
+            renderLink(writer, text, selectMonthAction, paramName, item);
+            text = null;
+        }
+        thMonth.endTag(text);
+        monthHeader.endTag();
+
+        HtmlTag weekHeader = writer.startTag("tr");
+        weekHeader.beginBody();
+
+        HtmlTag kwHead = writer.startTag("th");
+        kwHead.addAttribute("class", this.dayOfWeekClass);
+        kwHead.beginBody();
+        kwHead.endTag("KW");
+
+        for (int i = 0; i < 7; i++)
+        {
+            HtmlTag thWeekDays = writer.startTag("th");
+            thWeekDays.addAttribute("class", this.dayOfWeekClass);
+            thWeekDays.beginBody();
+            text = calendarInfo.getDayOfWeekText(i);
+            if (selectWeekdayAction != null)
+            {
+                renderLink(writer, text, selectWeekdayAction, paramName, item);
+                text = null;
+            }
+            thWeekDays.endTag(text);
+        }
+        weekHeader.endTag();
+    }
+
+    private void renderBody(HtmlWriter writer)
+    {
+        // for each week in a month
+        for (int i = 0; i < calendarInfo.getWeekCount(); i++)
+        {
+            HtmlTag weekRow = writer.startTag("tr");
+            weekRow.beginBody();
+
+            // for each day in a week
+            renderKalendarWeek(calendarInfo.getWeek(i), writer);
+            for (CalendarInfo.CalendarDayInfo day : calendarInfo.getWeek(i))
+            {
+                renderDay(day, writer);
+            }
+            weekRow.endTag();
+        }
+    }
+
+    private void renderKalendarWeek(CalendarDayInfo[] week, HtmlWriter writer)
+    {
+        int kw = calendarInfo.getKalendarWeek(week);
+        String bodyText = (kw!=0 ? kw + "" : "");
+        String linkItem = "";
+
+        for(int i=0;i<week.length;i++)
+        {
+            if(week[i]!=null)
+            {
+                linkItem = week[i].getLinkText();
+                break;
+            }
+        }
+        
+        // Render Tag
+        HtmlTag weekCell = writer.startTag("td");
+        weekCell.addAttribute("class", this.weekOfYearClass);
+        weekCell.beginBody();
+
+        if(StringUtils.isValid(bodyText) && StringUtils.isValid(selectWeekAction))
+            renderLink(writer, bodyText, selectWeekAction, paramName, linkItem);
+        else
+            weekCell.endTag("");
+    }
+
+    private void renderDay(CalendarDayInfo day, HtmlWriter writer)
+    {
+        String bodyText = null;
+        String linkItem = null;
+        String cssClass = null;
+        if (day != null)
+        {
+            bodyText = day.getText();
+            // Get Cell class
+            if (day.isToday())
+                cssClass = this.dateTodayClass;
+            else if (day.isSelected())
+                cssClass = this.dateSelectedClass;
+            else
+                cssClass = this.dateValidClass;
+            // Add a link
+            if (day.isLink() && selectDateAction != null)
+            {
+                linkItem = day.getLinkText();
+                // if (cssClass!= null)
+                // cssClass = cssClass + " " + this.dateLinkClass;
+                // else
+                if (!day.isSelected() && !day.isToday())
+                    cssClass = this.dateLinkClass;
+            }
+
+        } else
+        {
+            bodyText = "&nbsp;";
+            cssClass = dateEmptyClass;
+        }
+
+        // Render Tag
+        HtmlTag dateCell = writer.startTag("td");
+        dateCell.addAttribute("class", cssClass);
+        // dayCell.addAttribute("style", "text-align:center; width:25px; height:25px; border: 1px solid white;");
+        dateCell.beginBody();
+        if (linkItem != null)
+        {
+            renderLink(writer, bodyText, selectDateAction, paramName, linkItem);
+            bodyText = null;
+        }
+        dateCell.endTag(bodyText);
+    }
+
+    private void renderLink(HtmlWriter writer, String text, String action, String param, String value)
+    {
+        Map<String, Object> paramMap = null;
+        if (param != null)
+        {
+            paramMap = new Attributes();
+            paramMap.put(param, value);
+        }
+        // Render Link now
+        HtmlTag link = writer.startTag("a");
+        link.addAttribute("href", getUrl(action, paramMap));
+        link.beginBody(text);
+        link.endTag();
+    }
+
+    public String getUrl(String actionName, Map params)
+    {
+        String namespace = null;
+        String method = null;
+        String scheme = null;
+        boolean includeContext = true;
+        boolean encodeResult = true;
+        return this.determineActionURL(actionName, namespace, method, request, response, params, scheme, includeContext,
+                                       encodeResult);
+    }
+
+    // ------- Property setters -------
+
+    public void setCalendarInfo(CalendarInfo calendarInfo)
+    {
+        this.calendarInfo = calendarInfo;
+    }
+
+    public void setSelectDateAction(String selectDateAction)
+    {
+        this.selectDateAction = selectDateAction;
+    }
+
+    public void setSelectWeekdayAction(String selectWeekdayAction)
+    {
+        this.selectWeekdayAction = selectWeekdayAction;
+    }
+    
+    public void setSelectWeekAction(String selectWeekAction)
+    {
+        this.selectWeekAction = selectWeekAction;
+    }
+
+    public void setSelectMonthAction(String selectMonthAction)
+    {
+        this.selectMonthAction = selectMonthAction;
+    }
+
+    public void setCellpadding(String cellpadding)
+    {
+        this.cellpadding = cellpadding;
+    }
+
+    public void setCellspacing(String cellspacing)
+    {
+        this.cellspacing = cellspacing;
+    }
+
+    public void setDateEmptyClass(String dateEmptyClass)
+    {
+        this.dateEmptyClass = dateEmptyClass;
+    }
+
+    public void setDateLinkClass(String dateLinkClass)
+    {
+        this.dateLinkClass = dateLinkClass;
+    }
+
+    public void setDateSelectedClass(String dateSelectedClass)
+    {
+        this.dateSelectedClass = dateSelectedClass;
+    }
+
+    public void setDateTodayClass(String dateTodayClass)
+    {
+        this.dateTodayClass = dateTodayClass;
+    }
+
+    public void setDateValidClass(String dateValidClass)
+    {
+        this.dateValidClass = dateValidClass;
+    }
+
+    public void setDayOfWeekClass(String dayOfWeekClass)
+    {
+        this.dayOfWeekClass = dayOfWeekClass;
+    }
+    
+    public void setWeekOfYearClass(String weekOfYearClass)
+    {
+        this.weekOfYearClass = weekOfYearClass;
+    }
+
+    public void setMonthClass(String monthClass)
+    {
+        this.monthClass = monthClass;
+    }
+
+    public void setParamName(String paramName)
+    {
+        if (StringUtils.isValid(paramName))
+            this.paramName = paramName;
+    }
+
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/ControlComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/ControlComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/ControlComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/ControlComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,234 @@
+package org.apache.empire.struts2.jsp.components;
+
+import java.io.Writer;
+import java.util.Locale;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.commons.Options;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.data.Column;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.jsp.controls.InputControl;
+import org.apache.struts2.components.UIBean;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.LocaleProvider;
+import com.opensymphony.xwork2.TextProvider;
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public abstract class ControlComponent extends UIBean implements InputControl.ValueInfo
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(ControlComponent.class);
+
+    // Properties
+    protected Column     column;
+    protected Options    options;
+    protected Object     recordValue;
+    protected Object     nullValue;
+    protected String     bodyUsage;
+    protected String     format;
+
+    // The input control
+    private InputControl control;                                        // the control
+    private TextProvider textProvider;
+
+    protected ControlComponent(InputControl control, ValueStack stack, HttpServletRequest req, HttpServletResponse res)
+    {
+        super(stack, req, res);
+        // set the control
+        this.control = control;
+    }
+
+    @Override
+    protected String getDefaultTemplate()
+    {
+        return null;
+    }
+
+    @Override
+    public boolean start(Writer writer)
+    {
+        return super.start(writer);
+    }
+
+    @Override
+    public final boolean end(Writer writer, String body)
+    {
+        // evaluateParams();
+        try
+        { // No Value
+            if (recordValue == ObjectUtils.NO_VALUE)
+                return false;
+
+            // Render value
+            HtmlWriter hw = new HtmlWriter(writer);
+            render(hw, body, control);
+
+            return false; // do not evaluate body again!
+
+        } catch (Exception e)
+        {
+            log.error("error when rendering", e);
+            return false; // do not evaluate body again!
+        } finally
+        {
+            popComponentStack();
+        }
+    }
+
+    protected Object getAction()
+    {
+        try
+        {
+            return ActionContext.getContext().getActionInvocation().getAction();
+        } catch (Exception e)
+        {
+            log.fatal("Unable to detect Action. Action Invocation not available!");
+            return "";
+        }
+    }
+
+    private TextProvider getTextProvider(Object action)
+    {
+        if (action instanceof TextProvider)
+            return ((TextProvider) action);
+        // Error
+        return null;
+    }
+
+    public Locale getUserLocale()
+    {
+        Object action = getAction();
+        if (action instanceof LocaleProvider)
+            return ((LocaleProvider) action).getLocale();
+        // Default Locale
+        return ActionContext.getContext().getLocale();
+    }
+
+    public final String getTranslation(String text)
+    {
+        if (text == null || text.length() == 0 || !text.startsWith("!"))
+            return text;
+        // Get key. If key starts with ! then return key
+        String key = text.substring(1);
+        if (key.startsWith("!"))
+            return key;
+        // Get Text Provider
+        if (textProvider == null)
+        {
+            textProvider = getTextProvider(getAction());
+            if (textProvider == null)
+            { // Text Provider found
+                log.error("No Text Provider available for control component");
+                return "[" + key + "]";
+            }
+        }
+        // Tranlate text
+        String result = textProvider.getText(key);
+        if (result == null)
+        { // no Translation found
+            log.error("No translation found for key=" + key);
+            return "[" + key + "]";
+        }
+        // done
+        return result;
+    }
+
+    protected abstract void render(HtmlWriter hw, String body, InputControl control);
+
+    @Override
+    public boolean usesBody()
+    {
+        return StringUtils.isValid(bodyUsage);
+    }
+
+    public void setColumn(Column column)
+    {
+        this.column = column;
+    }
+
+    public void setOptions(Options options)
+    {
+        this.options = options;
+    }
+
+    public void setRecordValue(Object recordValue)
+    {
+        this.recordValue = recordValue;
+    }
+
+    public void setBodyUsage(String bodyUsage)
+    {
+        this.bodyUsage = bodyUsage;
+    }
+
+    public void setFormat(String format)
+    {
+        this.format = format;
+    }
+
+    // InputControl.ValueInfo
+
+    @Override
+    public String getId()
+    {
+        return id;
+    }
+
+    public final Column getColumn()
+    {
+        return column;
+    }
+
+    public final Options getOptions()
+    {
+        return options;
+    }
+
+    public final Object getValue()
+    {
+        return recordValue;
+    }
+
+    public final Object getNullValue()
+    {
+        return nullValue;
+    }
+
+    public final String getCssClass()
+    {
+        return cssClass;
+    }
+
+    public final String getCssStyle()
+    {
+        return cssStyle;
+    }
+
+    public final String getOnclick()
+    {
+        return onclick;
+    }
+
+    public final String getOndblclick()
+    {
+        return ondblclick;
+    }
+
+    public final String getFormat()
+    {
+        return format;
+    }
+
+    public void setNullValue(Object nullValue)
+    {
+        this.nullValue = nullValue;
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/DataValueComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/DataValueComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/DataValueComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/DataValueComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,111 @@
+package org.apache.empire.struts2.jsp.components;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+import org.apache.empire.struts2.jsp.controls.InputControl;
+
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public class DataValueComponent extends ControlComponent
+{
+    // Logger
+    @SuppressWarnings("hiding")
+    protected static Log log = LogFactory.getLog(DataValueComponent.class);
+
+    // the wrapper Tag
+    private String htmlTag;
+    
+    // Link
+    private String action;
+    private Object alt; // for the <a title="xxx" tag (alternative text)
+    private String anchorClass;
+    
+    public DataValueComponent(InputControl control, ValueStack stack, HttpServletRequest req, HttpServletResponse res)
+    {
+        super(control, stack, req, res);
+    }
+    
+    public String getURL(String actionName)
+    {
+        String namespace = null;
+        String method = null;
+        String scheme = null;
+        boolean includeContext = true;
+        boolean encodeResult = true;
+        return this.determineActionURL(actionName, namespace, method, request, response, parameters, scheme, includeContext, encodeResult);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void setParam(String key, String value)
+    {
+        if (value==null)
+        {   // Action
+            log.error("Action parameter '" + key + "' cannot be set to null!");
+            return;
+        }
+        parameters.put(key, value);
+    }
+    
+    // <td class="???"><a href="action!method" class=""/>value</a></td>
+    
+    @Override
+    protected void render(HtmlWriter hw, String body, InputControl control)
+    {
+        HtmlTag td = hw.startTag(htmlTag);
+        td.addAttribute("class", this.cssClass);
+        td.addAttribute("style", this.cssStyle);
+        td.beginBody();
+        // Add Link?
+        HtmlTag anchor = null;
+        if (action!=null)
+        {
+            String url = getURL(action);
+            // print href
+            anchor = hw.startTag("a");
+            anchor.addAttribute("href", url);
+            anchor.addAttribute("title", alt);
+            anchor.addAttribute("class", anchorClass);
+            anchor.addAttribute("onclick", onclick);
+            anchor.beginBody();
+        }
+        // Body prepend
+        if (usesBody() && "append".equalsIgnoreCase(bodyUsage)==false)
+            hw.print(body);
+        // Render Data
+        control.renderText(hw, this);
+        // Body append
+        if (usesBody() && "append".equalsIgnoreCase(bodyUsage))
+            hw.print(body);
+        // close anchor
+        if (anchor!=null)
+            anchor.endTag();
+        // close td
+        td.endTag();
+    }
+
+    public void setHtmlTag(String htmlTag)
+    {
+        this.htmlTag = htmlTag;
+    }
+
+    public void setAction(String action)
+    {
+        this.action = action;
+    }
+
+    public void setAnchorClass(String anchorClass)
+    {
+        this.anchorClass = anchorClass;
+    }
+    
+    public void setAlt(Object alt)
+    {
+        this.alt = alt;
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/FormComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/FormComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/FormComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/FormComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,99 @@
+package org.apache.empire.struts2.jsp.components;
+
+import java.io.Writer;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+import org.apache.struts2.components.Form;
+
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public class FormComponent extends Form
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(ControlComponent.class);
+    
+    // Internal use only
+    private HtmlTag formTag = null;
+    private boolean readOnly = false;
+
+    /*
+    <form id="login" name="login" onsubmit="return true;" action="/dbsample/login!doLogin.action;jsessionid=5A7C79EFBDCEB97C83918726B7D7EC3D" method="post">
+    <table class="wwFormTable">
+    */
+    
+    public FormComponent(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
+    {
+        super(stack, request, response);
+    }
+
+    @Override
+    public boolean start(Writer writer)
+    {
+        evaluateParams(); // We need to call this!
+        try {
+            
+            HtmlWriter htmlWriter = new HtmlWriter(writer);
+
+            // render form Tag?
+            if (readOnly==false)
+            {
+                formTag = htmlWriter.startTag("form");
+                formTag.addAttribute("id",       this.getId());
+                formTag.addAttribute("name",     this.name);
+                formTag.addAttribute("onsubmit", this.onsubmit);
+                formTag.addAttribute("action",   getURL(action));
+                formTag.addAttribute("method",   this.method);
+                formTag.addAttribute("enctype",  this.enctype);
+                formTag.beginBody(true);
+            }
+            
+        } catch (Exception e) {
+            log.error("error when rendering", e);
+        }
+        return true;
+    }
+    
+    @Override
+    public boolean end(Writer writer, String body)
+    {
+        // super.end(writer, body);
+        // evaluateParams();
+        try {
+            
+            if (formTag!=null)
+                formTag.endTag(true);
+            
+            return false; // do not evaluate body again!
+            
+        } catch (Exception e) {
+            log.error("error when rendering", e);
+            return false; // do not evaluate body again!
+        }
+        finally {
+            popComponentStack();
+        }
+    }
+
+    private String getURL(String action)
+    {
+        String namespace = null;
+        String method = null;
+        String scheme = null;
+        boolean includeContext = true;
+        boolean encodeResult = true;
+        return this.determineActionURL(action, namespace, method, request, response, null, scheme, includeContext, encodeResult);
+    }
+
+    public void setReadOnly(boolean readOnly)
+    {
+        this.readOnly = readOnly;
+    }
+    
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/InputControlComponent.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/InputControlComponent.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/InputControlComponent.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/InputControlComponent.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,346 @@
+package org.apache.empire.struts2.jsp.components;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.empire.commons.ErrorInfo;
+import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.data.DataType;
+import org.apache.empire.struts2.action.ActionErrorProvider;
+import org.apache.empire.struts2.html.HtmlTagDictionary;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+import org.apache.empire.struts2.jsp.controls.InputControl;
+
+import com.opensymphony.xwork2.util.ValueStack;
+
+
+public class InputControlComponent extends ControlComponent implements InputControl.ControlInfo
+{
+    public enum RenderType
+    {
+        ALL,
+        LABEL,
+        CONTROL,
+        INPUTLABEL,
+        INPUTCONTROL,
+        HIDDEN
+    }
+
+    public enum DisabledMode
+    {
+        DEFAULT,
+        TEXT,
+        TEXTHIDDEN,
+        CONTROL,
+        CONTROLHIDDEN,
+    }
+    
+    private int hSize;
+    private int vSize;
+    private boolean readOnly;
+    private String labelClass;
+    private String labelStyle;
+    
+    private RenderType renderType  = RenderType.ALL;
+    private DisabledMode disabledMode = DisabledMode.DEFAULT;
+
+    public InputControlComponent(InputControl control, ValueStack stack, HttpServletRequest req, HttpServletResponse res)
+    {
+        super(control, stack, req, res);
+    }
+
+    /*
+    private Form findForm()
+    {
+        final Form form = (Form) findAncestor(Form.class);
+        if (form != null)
+        {
+            log.info("Control belongs to form: " + form.toString());
+            if (id == null)
+            {
+                String formId = form.getId();
+                if (formId != null && formId.length() > 0 && formId.indexOf('.')<0)
+                    id = formId + "." + name;
+                else
+                    id = name;
+            }
+        }
+        return form;
+    }
+    */
+
+    @Override
+    protected void render(HtmlWriter writer, String body, InputControl control)
+    {
+        HtmlTagDictionary dic = HtmlTagDictionary.getInstance();
+        
+        // Check Render Type
+        if (renderType==RenderType.HIDDEN)
+        {   // Render Hidden input
+            renderHiddenValue(writer);
+        }
+        else if (renderType==RenderType.LABEL)
+        {
+            // Render Label only
+            HtmlTag label = writer.startTag("label");
+            label.addAttribute("class", StringUtils.coalesce(this.labelClass, this.cssClass));
+            label.addAttribute("style", StringUtils.coalesce(this.labelStyle, this.cssStyle));
+            if (control.useLabelId())
+                label.addAttribute("for", getId());
+            label.beginBody(this.label);
+            label.endTag();
+        }
+        else if (renderType==RenderType.CONTROL)
+        {   // Render Input
+            if (renderControlAsData(dic))
+            {   // Render Input as Data
+                control.renderText(writer, this);
+            }
+            else
+            {   // Render Input as Control
+                control.renderInput(writer, this);
+            }
+            // Additionally render hidden value?
+            if (renderHidden())
+                renderHiddenValue(writer);
+        }
+        else
+        {   // Check wether to render all 
+            boolean renderWrapper =(renderType==RenderType.ALL);
+            
+            // the wrapper (only if renderLabel && renderControl are both true)
+            HtmlTag wrapper = writer.startTag((renderWrapper ? dic.InputWrapperTag() : null));
+            wrapper.addAttribute("class", dic.InputWrapperClass());
+            wrapper.beginBody(true);
+
+            if (renderType!=RenderType.INPUTCONTROL)
+            {
+                HtmlTag wrapLabel = writer.startTag(dic.InputLabelTag());
+                wrapLabel.addAttribute("class", dic.InputLabelClass());
+                wrapLabel.beginBody();
+                // label
+                HtmlTag label = writer.startTag("label");
+                if (control.useLabelId())
+                    label.addAttribute("for", getId());
+                label.addAttribute("class", this.labelClass);
+                label.addAttribute("style", this.labelStyle);
+                label.beginBody(this.label);
+                label.endTag(":");
+                // required
+                if ("true".equals(this.required) && readOnly == false)
+                {
+                    HtmlTag required = writer.startTag(dic.InputRequiredTag());
+                    required.addAttribute("class", dic.InputRequiredClass());
+                    required.beginBody("*");
+                    required.endTag();
+                }
+                // close
+                wrapLabel.endTag((renderType!=RenderType.INPUTLABEL));
+            }
+
+            // render Control
+            if (renderType!=RenderType.INPUTLABEL)
+            {
+                HtmlTag wrapCtrl = writer.startTag(dic.InputControlTag());
+                // Render Input
+                if (renderControlAsData(dic))
+                {   // Render Input as Data
+                    wrapCtrl.addAttribute("class", dic.InputReadOnlyClass());
+                    wrapCtrl.beginBody();
+                    readOnly = true;
+                    control.renderText(writer, this);
+                }
+                else
+                {   // Render Input as Control
+                    wrapCtrl.addAttribute("class", dic.InputControlClass());
+                    wrapCtrl.beginBody();
+                    control.renderInput(writer, this);
+                }
+                // Additionally render hidden value?
+                if (renderHidden())
+                    renderHiddenValue(writer);
+                // End Tag
+                wrapCtrl.endTag(renderWrapper);
+            }
+            
+            // Done
+            String wrapperBody = (wrapper.isValid()) ? dic.InputWrapperBody() : null;  
+            wrapper.endTag(wrapperBody);
+        }
+    }
+    
+    private boolean renderHidden()
+    {   // render hidden
+        if (readOnly==false)
+            return false;
+        return (disabledMode==DisabledMode.CONTROLHIDDEN || disabledMode==DisabledMode.TEXTHIDDEN);
+    }
+    
+    private boolean renderControlAsData(HtmlTagDictionary dic)
+    {   // Render Input
+        if (readOnly==false)
+            return false;
+        if (disabledMode==DisabledMode.DEFAULT)
+            return dic.InputReadOnlyAsData();
+        return (disabledMode==DisabledMode.TEXT || disabledMode==DisabledMode.TEXTHIDDEN);
+    }
+    
+    private void renderHiddenValue(HtmlWriter writer)
+    {
+        // Render Hidden input
+        HtmlTag input = writer.startTag("input");
+        input.addAttribute("type", "hidden");
+        input.addAttribute("name", getName()+ "!");
+        // Get Value
+        String value;
+        if (recordValue instanceof Date)
+        {   // Special for Dates and timestamps
+            String format = (column!=null && column.getDataType()==DataType.DATE) ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss.S";
+            SimpleDateFormat sdf = new SimpleDateFormat(format);
+            value = sdf.format(recordValue);
+        }
+        else
+        {   // Let Record do the conversion
+            value = StringUtils.valueOf(recordValue); 
+        }
+        // Add Value Attribute
+        if (value.length()>0)
+            input.addAttribute("value", value);
+        else
+            writer.print("value=\"\"");
+        input.endTag();
+    }
+    
+    public void setReadOnly(boolean readOnly)
+    {
+        this.readOnly = readOnly;
+    }
+
+    public void setRenderType(String type)
+    {
+        if (type==null)
+            renderType = RenderType.ALL;
+        else if (type.equalsIgnoreCase("label"))
+            renderType = RenderType.LABEL;
+        else if (type.equalsIgnoreCase("control"))
+            renderType = RenderType.CONTROL;
+        else if (type.equalsIgnoreCase("inputlabel"))
+            renderType = RenderType.INPUTLABEL;
+        else if (type.equalsIgnoreCase("inputcontrol"))
+            renderType = RenderType.INPUTCONTROL;
+        else if (type.equalsIgnoreCase("hidden"))
+            renderType = RenderType.HIDDEN;
+        else
+            renderType = RenderType.ALL;
+    }
+
+    public void setDisabledMode(String type)
+    {
+        if (type==null)
+            disabledMode = DisabledMode.DEFAULT;
+        else if (type.equalsIgnoreCase("text"))
+            disabledMode = DisabledMode.TEXT;
+        else if (type.equalsIgnoreCase("textHidden"))
+            disabledMode = DisabledMode.TEXTHIDDEN;
+        else if (type.equalsIgnoreCase("control"))
+            disabledMode = DisabledMode.CONTROL;
+        else if (type.equalsIgnoreCase("controlHidden"))
+            disabledMode = DisabledMode.CONTROLHIDDEN;
+        else
+            disabledMode = DisabledMode.DEFAULT;
+    }
+    
+    public void setHSize(String size)
+    {
+        hSize = ObjectUtils.getInteger(size, 0);
+    }
+
+    public void setVSize(String size)
+    {
+        vSize = ObjectUtils.getInteger(size, 0);
+    }
+    
+    // InputControl.InputInfo
+
+    @Override
+    public String getId()
+    {
+        return ((id == null) ? name : id);
+    }
+
+    public final String getName()
+    {
+        return name;
+    }
+
+    public final boolean getDisabled()
+    {
+        return readOnly;
+    }
+
+    public final String getTabindex()
+    {
+        return tabindex;
+    }
+
+    public final String getAccesskey()
+    {
+        return accesskey;
+    }
+
+    public final String getOnchange()
+    {
+        return onchange;
+    }
+
+    public final String getOnfocus()
+    {
+        return onfocus;
+    }
+
+    public final String getOnblur()
+    {
+        return onblur;
+    }
+    
+    public final boolean hasError()
+    {
+        Object action = getAction();
+        if (action instanceof ActionErrorProvider)
+        {
+            Map<String, ErrorInfo> map = ((ActionErrorProvider)action).getItemErrors();
+            return (map!=null && map.containsKey(getName()));
+        }
+        // don't know, assume no
+        return false;
+    }
+
+    public int getHSize()
+    {
+        if (hSize== 0)
+            hSize = HtmlTagDictionary.getInstance().InputMaxCharSize();
+        return hSize;
+    }
+
+    public int getVSize()
+    {
+        return vSize;
+    }
+
+    public void setLabelClass(String labelClass)
+    {
+        this.labelClass = labelClass;
+    }
+
+    public void setLabelStyle(String labelStyle)
+    {
+        this.labelStyle = labelStyle;
+    }
+
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,301 @@
+/*
+ * ESTEAM Software GmbH, 13.08.2007
+ */
+package org.apache.empire.struts2.jsp.components.info;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.DateUtils;
+import org.apache.empire.struts2.jsp.components.ControlComponent;
+
+
+public class CalendarInfo
+{
+    // Logger
+    protected static Log log = LogFactory.getLog(ControlComponent.class);
+
+    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+    
+    public static String formatDate(Date date)
+    {
+        return dateFormat.format(date);
+    }
+    
+    public static Date parseDate(String date)
+    {
+        if (date==null || date.length()!=dateFormat.toPattern().length())
+        {   // Error: Invalid Date supplied. Using Today
+            log.error("Invalid date format: " + String.valueOf(date));
+            return DateUtils.getDateNow();
+        }
+        try
+        {   // See, if a date is supplied on the request
+            return dateFormat.parse(date);
+            
+        } catch (ParseException e)
+        {   // Unable to parse Date
+            log.error("Invalid date format: " + date, e);
+            return DateUtils.getDateNow();
+        }
+    }
+    
+    public static class CalendarDayInfo
+    {
+        private Date date;
+        private boolean link;
+        private boolean selected;
+        private boolean today;
+        private String text;
+        
+        public CalendarDayInfo(Date date, String text, boolean isToday)
+        {
+            this.date = date;
+            this.text = text;
+            this.link = false;
+            this.today = isToday;
+        }
+        public Date getDate()
+        {
+            return date;
+        }
+        public boolean isToday()
+        {
+            return today;
+        }
+        public String getText()
+        {
+            return text;
+        }
+        public String getLinkText()
+        {
+            return CalendarInfo.formatDate(date);
+        }
+        public boolean isLink()
+        {
+            return link;
+        }
+        public void setLink(boolean link)
+        {
+            this.link = link;
+        }
+        public boolean isSelected()
+        {
+            return selected;
+        }
+        public void setSelected(boolean selected)
+        {
+            this.selected = selected;
+        }
+    }
+    
+    private Locale locale;
+    private CalendarDayInfo[][] days = new CalendarDayInfo[6][7];
+    private int year;
+    private int month;
+    private Date date = null;
+
+    private String[] months;
+    private String[] weekdays;
+    
+    public CalendarInfo(Locale locale)
+    {
+        this.locale = locale;
+
+        SimpleDateFormat sdf = new SimpleDateFormat("", locale);
+        this.months = sdf.getDateFormatSymbols().getMonths();
+        this.weekdays = sdf.getDateFormatSymbols().getShortWeekdays();
+        
+    }
+    
+    public void init(int year, int month)
+    {
+        this.year = year;
+        this.month = month;
+        Calendar calendar = Calendar.getInstance(locale);
+        calendar.setFirstDayOfWeek(Calendar.MONDAY);
+
+        Date today = DateUtils.getDateNow();
+        calendar.set(year, month, 1, 0, 0, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        this.date = calendar.getTime(); 
+
+        // Init all calendar cells
+        for (int w = 0; w< days.length; w++)
+        {
+            int dayOfWeek = getDayOfWeek(calendar);
+            for (int d=dayOfWeek; d<days[w].length; d++)
+            {
+                Date date = calendar.getTime();
+                String sDay = "&nbsp;" + String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)) + "&nbsp;";         
+                
+                days[w][d] = new CalendarDayInfo(date, sDay, date.equals(today));
+                // Next Day
+                calendar.add(Calendar.DAY_OF_MONTH, 1);
+
+                if(month!=calendar.get(Calendar.MONTH))
+                    // finish month
+                    return;
+            }
+        }
+    }
+    
+    // ------- Properties -------
+
+    public int getWeekCount()
+    {
+        return days.length;
+    }
+    
+    public CalendarDayInfo[] getWeek(int i)
+    {
+        return days[i]; 
+    }
+    
+    public CalendarDayInfo getDayInfo(Date date)
+    {
+        if (date==null)
+            return null;
+        // Init Calendar
+        Calendar cal = Calendar.getInstance(locale);
+        cal.setTime(date);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        date = cal.getTime();
+        // Search for Day
+        for (int w = 0; w< days.length; w++)
+        {
+            for (int d=0; d<days[w].length; d++)
+            {
+                CalendarDayInfo cdi = days[w][d]; 
+                if (cdi!=null && cdi.date.equals(date))
+                {
+                   return cdi;
+                }
+            }
+        }
+        // Date not found
+        return null;
+    }
+    
+    public boolean getLink(Date date)
+    {
+        CalendarDayInfo cdi = getDayInfo(date);
+        return (cdi!=null ? cdi.link : null);
+    }
+    
+    public void setLink(Date date, boolean link)
+    {
+        CalendarDayInfo cdi = getDayInfo(date);
+        if (cdi!=null)
+            cdi.setLink(link);
+    }
+    
+    public void setSelected(boolean selected)
+    {
+        for (int w = 0; w< days.length; w++)
+        {
+            for (int d=0; d<days[w].length; d++)
+            {
+                if(days[w][d]!=null)
+                   days[w][d].setSelected(selected);
+            }
+        }
+    }
+    
+    public void setSelected(Date date, boolean selected)
+    {
+        CalendarDayInfo cdi = getDayInfo(date);
+        if (cdi!=null)
+            cdi.setSelected(selected);
+    }
+    
+    public void setSelected(int kalendarWeek ,boolean selected)
+    {
+        int kw = 0;
+        for (int w = 0; w< days.length; w++)
+        {
+            kw = getKalendarWeek(days[w]);
+            if(kw != 0 && kalendarWeek == kw)
+                setSelected(days[w],selected);
+        }
+    }  
+
+    public int getMonth()
+    {
+        return month;
+    }
+    
+    public int getYear()
+    {
+        return year;
+    }
+    
+    public String getLinkText()
+    {
+        return formatDate(date);
+    }
+    
+    public String getMonthText()
+    {
+        return ((month>=0 && month<months.length) ? months[month] : "");
+    }
+    
+    public String getYearText()
+    {
+        return String.valueOf(year);
+    }
+    
+    public String getDayOfWeekText(int day)
+    {
+        if(day==6)
+            return weekdays[1];
+        else
+            return weekdays[day+2];
+    }
+    
+    public int getKalendarWeek(CalendarDayInfo[] week)
+    {
+        CalendarDayInfo validDay = null;
+        int retVal = 0;
+        for (int i = 0;week!=null &&  i<week.length; i++)
+        {
+            validDay = week[i];
+            if (validDay != null)
+            {
+                retVal = DateUtils.getWeekOfYear(validDay.getDate(),locale);
+                break;
+            }
+        }
+        return retVal;
+    }
+    
+    // ------- Helpers -------
+    
+    private int getDayOfWeek(Calendar c)
+    {
+        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
+        if( dayOfWeek == Calendar.SUNDAY)
+            dayOfWeek=6;
+        else
+            dayOfWeek-=2;
+        
+        return dayOfWeek;
+    }
+    
+    private void setSelected(CalendarDayInfo[] week, boolean selected)
+    {
+        for (int d=0; d<week.length; d++)
+        {
+            if(week[d]!=null)
+                week[d].setSelected(selected);
+        }
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/package.html?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/package.html (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/info/package.html Wed Aug  6 02:34:41 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/package.html?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/package.html (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/components/package.html Wed Aug  6 02:34:41 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/CheckboxInputControl.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/CheckboxInputControl.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/CheckboxInputControl.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/CheckboxInputControl.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,81 @@
+package org.apache.empire.struts2.jsp.controls;
+
+import java.util.Locale;
+
+import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.data.Column;
+import org.apache.empire.struts2.action.RequestParamProvider;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+
+
+public class CheckboxInputControl extends InputControl
+{
+    private static String CHECK_POSTFIX = "__CBCHECK";
+
+    @Override
+    public Object getFieldValue(String name, RequestParamProvider request, Locale locale, Column column)
+    {
+        // If the checkbox was checked then a value is present in request params
+        // otherwise no value will be present.
+        String val = request.getRequestParam(name);
+        if (val!=null)
+            return Boolean.TRUE;
+        // Is Hidden Value present   
+        if (request.getRequestParam(name + CHECK_POSTFIX)==null)
+            return NO_VALUE;
+        // Checkbox is present, but was unchecked
+        return Boolean.FALSE;
+    }
+
+    @Override
+    public void renderText(HtmlWriter writer, ValueInfo vi)
+    {
+        // Always render checkboxes as controls
+        HtmlTag input = writer.startTag("input");
+        input.addAttribute("type", "checkbox");
+        input.addAttribute("id",    vi.getId());
+        input.addAttribute("class", vi.getCssClass());
+        input.addAttribute("style", vi.getCssStyle());
+        input.addAttribute("disabled");
+        // Decide whether to render the checkbox checked or not.
+        if (ObjectUtils.getBoolean(vi.getValue()))
+            input.addAttribute("checked");
+        input.endTag();
+    }
+    
+    @Override
+    public void renderInput(HtmlWriter writer, ControlInfo ci)
+    {
+        if (ci.getDisabled())
+        {   // render disabled
+            renderText(writer, ci);
+            return;
+        }
+        // Render enabled
+        HtmlTag input = writer.startTag("input");
+        input.addAttribute("type", "checkbox");
+        input.addAttribute("id",    ci.getId());
+        input.addAttribute("class", ci.getCssClass());
+        input.addAttribute("style", ci.getCssStyle());
+        input.addAttribute("name",  ci.getName());
+        // Decide whether to render the checkbox checked or not.
+        if (ObjectUtils.getBoolean(ci.getValue()))
+        {
+            input.addAttribute("checked");
+        }
+        // Event Attributes
+        input.addAttribute("onclick",   ci.getOnclick());
+        input.addAttribute("onchange",  ci.getOnchange());
+        input.addAttribute("onfocus",   ci.getOnfocus());
+        input.addAttribute("onblur",    ci.getOnblur());
+        input.endTag();
+        // Additionally add a hidden field
+        // to detect unchecked state
+        HtmlTag hidden = writer.startTag("input");
+        hidden.addAttribute("type",  "hidden");
+        hidden.addAttribute("name",  ci.getName() + CHECK_POSTFIX);
+        hidden.addAttribute("value", ci.getValue());
+        hidden.endTag();
+    }
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/EMailInputControl.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/EMailInputControl.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/EMailInputControl.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/EMailInputControl.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,31 @@
+/*
+ * ESTEAM Software GmbH, 30.07.2007
+ */
+package org.apache.empire.struts2.jsp.controls;
+
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+
+
+public class EMailInputControl extends TextInputControl
+{
+
+    @Override
+    public void internalRenderText(HtmlWriter writer, ValueInfo vi)
+    {
+        String text = formatValue(vi);
+        if (StringUtils.isEmpty(text))
+            return;
+        
+        // Show Link
+        HtmlTag a = writer.startTag("a");
+        a.addAttribute("href", "mailto:" + text);
+        a.addAttribute("id",    vi.getId());
+        a.addAttribute("class", vi.getCssClass());
+        a.addAttribute("style", vi.getCssStyle());
+        a.beginBody(text);
+        a.endTag();
+    }
+
+}

Added: incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/HLinkInputControl.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/HLinkInputControl.java?rev=683198&view=auto
==============================================================================
--- incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/HLinkInputControl.java (added)
+++ incubator/empire-db/trunk/struts2-ext/Empire-struts2-ext/src/org/apache/empire/struts2/jsp/controls/HLinkInputControl.java Wed Aug  6 02:34:41 2008
@@ -0,0 +1,35 @@
+/*
+ * ESTEAM Software GmbH, 30.07.2007
+ */
+package org.apache.empire.struts2.jsp.controls;
+
+import org.apache.empire.commons.StringUtils;
+import org.apache.empire.struts2.html.HtmlWriter;
+import org.apache.empire.struts2.html.HtmlWriter.HtmlTag;
+
+
+public class HLinkInputControl extends TextInputControl
+{
+
+    @Override
+    public void internalRenderText(HtmlWriter writer, ValueInfo vi)
+    {
+        String text = formatValue(vi);
+        if (StringUtils.isEmpty(text))
+            return;
+        // Get HRef
+        String href = text; 
+        if (text.indexOf("://")<0)
+            href = "http://" + text;
+        // Show Link
+        HtmlTag a = writer.startTag("a");
+        a.addAttribute("href",  href);
+        a.addAttribute("id",    vi.getId());
+        a.addAttribute("class", vi.getCssClass());
+        a.addAttribute("style", vi.getCssStyle());
+        a.addAttribute("target", "_blank");
+        a.beginBody(text);
+        a.endTag();
+    }
+
+}



Mime
View raw message