mindbridge    2005/08/14 07:12:56

  Modified:    contrib/src/java/org/apache/tapestry/contrib Contrib.library
  Added:       contrib/src/java/org/apache/tapestry/contrib/ajax
                        Timeout.properties Timeout.script XTileService.java
                        IXTile.java Timeout.html Timeout.java XTile.java
                        Timeout.jwc XTile.script XTile.html XTile.jwc
               contrib/src/java/org/apache/tapestry/contrib/form/checkboxes
                        ControlledCheckbox.html ControlCheckbox.html
                        ControlCheckbox.java ControlledCheckbox.jwc
                        CheckboxGroup.jwc CheckboxGroup.java
                        ControlledCheckbox.java ControlCheckbox.jwc
                        CheckboxGroup.script CheckboxGroup.html
               contrib/src/java/org/apache/tapestry/contrib/link
                        FormLinkRenderer.java
  Log:
  Adding the checkboxes and xtile components to contrib
  
  Revision  Changes    Path
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/Timeout.properties
  
  Index: Timeout.properties
  ===================================================================
  warning=The connection was inactive for more than {0} minutes. Your session 
will expire at {1}.\\n Please click OK to continue your work or CANCEL to close 
the session.
  expiration=Your session has expired. Please log in again.
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/Timeout.script
  
  Index: Timeout.script
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE script PUBLIC
        "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd";>
  <script>
        <input-symbol key="confirmTimeout" class="java.lang.Integer"/>
        <input-symbol key="expirationTimeout" class="java.lang.Integer"/>
        <input-symbol key="prolongSessionPeriod" class="java.lang.Integer"/>
  
        <input-symbol key="confirmMessage" class="java.lang.String"/>
        <input-symbol key="expirationMessage" class="java.lang.String"/>
  
        <input-symbol key="disableWarning" class="java.lang.Boolean"/>
        <input-symbol key="disableAutoProlong" class="java.lang.Boolean"/>
        
        <input-symbol key="expirationFunction" class="java.lang.String"/>
  
        <body>
      var TimeoutTimerConfirm;
      var TimeoutProlongSessionTime;
      var TimeoutExpirationTime;
      
      <if expression="!disableWarning">
      function TimeoutConfirm()
      {
        TimeoutClearConfirmTimer();
      
        var exp = new Date();
        exp.setTime(exp.getTime() + ${expirationTimeout});
            var hrs = exp.getHours();
        var min = exp.getMinutes();
        if (min &lt; 10)
              mins = "0" + min;
          else
              mins = min;
      
        var confirmMessage = "${confirmMessage}";
        confirmMessage = confirmMessage.replace("{0}", 
Math.round(${confirmTimeout}/60000));
        confirmMessage = confirmMessage.replace("{1}", hrs + ":" + mins);
  
        var val = confirm(confirmMessage);
          if (!val) {
                    <if expression="expirationFunction != null">
                    ${expirationFunction}();
                    </if>
                return;
          }
              
          var current = new Date();
          if (current.getTime() &gt; exp.getTime()) {
              alert("${expirationMessage}");
                    <if expression="expirationFunction != null">
                    ${expirationFunction}();
                    </if>
          }
          else {
                TimeoutProlongSession();
          }
      }
      </if>
      
      function TimeoutProlongSession()
      {
            TimeoutUpdateProlongSessionTime();
                TimeoutRenewSession();
      }
      
      function TimeoutSessionRenewed()
      {
        TimeoutClearConfirmTimer();
        TimeoutInitConfirmTimer();
      }
      
      function TimeoutClearConfirmTimer()
      {
        window.clearTimeout(TimeoutTimerConfirm);
      }
      
      function TimeoutInitConfirmTimer()
      {
            <if expression="!disableWarning">
        TimeoutTimerConfirm = window.setTimeout("TimeoutConfirm()", 
${confirmTimeout});
        </if>
  
        TimeoutExpirationTime = new Date();
        TimeoutExpirationTime.setTime(TimeoutExpirationTime.getTime() + 
${confirmTimeout} + ${expirationTimeout});
  
                TimeoutUpdateProlongSessionTime();
      }
      
      function TimeoutUpdateProlongSessionTime()
      {
        TimeoutProlongSessionTime = new Date();
        TimeoutProlongSessionTime.setTime(TimeoutProlongSessionTime.getTime() + 
${prolongSessionPeriod});
      }
  
      <if expression="!disableAutoProlong">
        var TimeoutPreviousOnClick;
        var TimeoutPreviousOnMouseMove;
        var TimeoutPreviousOnKeyPress;
        var TimeoutPreviousOnScroll;
        
      function TimeoutInitChangeObserver()
      {
        TimeoutPreviousOnClick = document.body.onclick;
          document.body.onclick = TimeoutHandleOnClick;
          
          TimeoutPreviousMouseMove = document.body.onmousemove;
          document.body.onmousemove = TimeoutHandleOnMouseMove;
          
          TimeoutPreviousOnKeyPress = document.body.onkeydown;
          document.body.onkeydown = TimeoutHandleOnKeyPress;
          
          TimeoutPreviousOnScroll = window.onscroll;
          window.onscroll = TimeoutHandleOnScroll;
      }
      
      function TimeoutHandleOnClick() {
        if (TimeoutPreviousOnClick) TimeoutPreviousOnClick();
        TimeoutRegisterUserAction();
      }
      
      function TimeoutHandleOnMouseMove() {
        if (TimeoutPreviousOnMouseMove) TimeoutPreviousOnMouseMove();
        TimeoutRegisterUserAction();
      }
      
      function TimeoutHandleOnKeyPress() {
        if (TimeoutPreviousOnKeyPress) TimeoutPreviousOnKeyPress();
        TimeoutRegisterUserAction();
      }
      
      function TimeoutHandleOnScroll() {
        if (TimeoutPreviousOnScroll) TimeoutPreviousOnScroll();
        TimeoutRegisterUserAction();
      }
      
      function TimeoutRegisterUserAction()
      {
        var now = new Date();
        if (now.getTime() &gt; TimeoutProlongSessionTime.getTime() &amp;&amp;
                now.getTime() &lt; TimeoutExpirationTime.getTime())
                TimeoutProlongSession();
          return true;
      }
      </if>
        </body>
        
        <initialization>
            <if expression="!disableAutoProlong">
            TimeoutInitChangeObserver();
            </if>
            TimeoutInitConfirmTimer();
        </initialization>
        
  </script>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/XTileService.java
  
  Index: XTileService.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.ajax;
  
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.StringWriter;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.tapestry.IComponent;
  import org.apache.tapestry.IPage;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.IEngineService;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.error.RequestExceptionReporter;
  import org.apache.tapestry.request.RequestContext;
  import org.apache.tapestry.services.ServiceConstants;
  import org.apache.tapestry.util.ContentType;
  import org.apache.tapestry.web.WebResponse;
  import org.w3c.dom.Document;
  import org.w3c.dom.Node;
  
  /**
   * @author mindbridge
   * @author Paul Green
   * @since 4.0
   */
  public class XTileService implements IEngineService 
  {
      public static final String SERVICE_NAME = "xtile";
  
      private RequestExceptionReporter _exceptionReporter;
      private WebResponse _response;
      
        public String getName() 
        {
                return SERVICE_NAME;
        }
        
        public ILink getLink(IRequestCycle cycle, boolean post, Object 
parameter) {
                throw new UnsupportedOperationException();
        }
        
        public void service(IRequestCycle cycle) throws IOException {
          String pageName = cycle.getParameter(ServiceConstants.PAGE);
          String componentId = cycle.getParameter(ServiceConstants.COMPONENT);
          
          IPage componentPage = cycle.getPage(pageName);
          IComponent component = componentPage.getNestedComponent(componentId);
          
          if (!(component instanceof IXTile))
                throw new ApplicationRuntimeException("Incorrect component 
type: was " + component.getClass() + " but must be " + IXTile.class, 
                                component, null, null);
          
          IXTile xtile = (IXTile) component;
          
          // do not squeeze on input
                RequestContext context = cycle.getRequestContext();
          String[] params = context.getParameters(ServiceConstants.PARAMETER);
          cycle.setServiceParameters(params);
          xtile.trigger(cycle);
          
          // do not squeeze on output either
          Object[] args = cycle.getServiceParameters();
          String strArgs = generateOutputString(args);
          if (strArgs != null) {
                OutputStream output = _response.getOutputStream(new 
ContentType("text/xml"));
                output.write(strArgs.getBytes("utf-8"));
          }
        }
        
        protected String generateOutputString(Object[] args)
        {
                try {
                        DocumentBuilderFactory dbf = 
DocumentBuilderFactory.newInstance();
                        dbf.setValidating(false);
                        DocumentBuilder db = dbf.newDocumentBuilder();
                        Document doc = db.newDocument();
  
                        Node rootNode = doc.createElement("data");
                        doc.appendChild(rootNode);
                        
                        if (args != null) {
                                for (int i = 0; i < args.length; i++) {
                                        Object value = args[i];
                                        
                                        Node spNode = doc.createElement("sp");
                                        rootNode.appendChild(spNode);
                                        
                                        Node valueNode = 
doc.createTextNode(value.toString());
                                        spNode.appendChild(valueNode);
                                }
                        }
                        
                        TransformerFactory trf = 
TransformerFactory.newInstance();
                        Transformer tr = trf.newTransformer();
                        tr.setOutputProperty(OutputKeys.INDENT, "yes");
  
                        DOMSource domSrc = new DOMSource(doc);
                        StringWriter writer = new StringWriter();
                        StreamResult res = new StreamResult(writer);
                        tr.transform(domSrc, res);
                        writer.close();
                        
                        return writer.toString();
                } 
                catch (Exception e) {
                        _exceptionReporter.reportRequestException("Cannot 
generate XML", e);
                        return null;
                }
        }
  
      public void setExceptionReporter(RequestExceptionReporter 
exceptionReporter)
      {
          _exceptionReporter = exceptionReporter;
      }
  
      public void setResponse(WebResponse response)
      {
          _response = response;
      }
      
        public static void main(String[] args) {
                XTileService objService = new XTileService();
                System.out.println(objService.generateOutputString(new Object[] 
{ "test > work", new Integer(20) }));
        }
  
  
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/IXTile.java
  
  Index: IXTile.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.ajax;
  
  import org.apache.tapestry.IRequestCycle;
  
  /**
   * @author mindbridge
   * @since 4.0
   */
  public interface IXTile 
  {
        public void trigger(IRequestCycle cycle);
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/Timeout.html
  
  Index: Timeout.html
  ===================================================================
  <span jwcid="@If" condition="ognl:inSession">
  <span jwcid="script"/><span jwcid="@XTile" 
listener="ognl:listeners.renewSession" 
        sendName="TimeoutRenewSession" receiveName="TimeoutSessionRenewed" 
disableCaching="true"/>
  </span>
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/Timeout.java
  
  Index: Timeout.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.ajax;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.servlet.http.HttpSession;
  
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IRequestCycle;
  
  /**
   * @author mb
   * @since 4.0
   */
  public abstract class Timeout extends BaseComponent {
        public abstract int getWarningTime();
        public abstract int getAutoProlongTime();
        
        public abstract String getWarningMessage();
        public abstract String getExpirationMessage();
  
        public abstract boolean getDisableWarning();
        public abstract boolean getDisableAutoProlong();
        
        public abstract String getExpirationFunction();
        
        protected HttpSession getSession()
        {
                return 
getPage().getRequestCycle().getRequestContext().getSession();
        }
        
        protected int getSessionTime()
        {
                return getSession().getMaxInactiveInterval();
        }
        
        public boolean isInSession()
        {
                HttpSession session = getSession();
                return session != null;
        }
        
        public Map getScriptSymbols()
        {
                int nSessionTime = getSessionTime();
                int nTimeToMessage = nSessionTime - getWarningTime();
                if (nTimeToMessage < 0)
                        nTimeToMessage = 0;
                int nRemainingTime = nSessionTime - nTimeToMessage;
                int nAutoProlongTime = nSessionTime - getAutoProlongTime();
                
                Map mapSymbols = new HashMap();
                mapSymbols.put("confirmTimeout", new 
Integer(nTimeToMessage*1000));
                mapSymbols.put("expirationTimeout", new 
Integer(nRemainingTime*1000));
                mapSymbols.put("prolongSessionPeriod", new 
Integer(nAutoProlongTime*1000));
                mapSymbols.put("confirmMessage", getWarningMessage());
                mapSymbols.put("expirationMessage", getExpirationMessage());
                mapSymbols.put("disableWarning", new 
Boolean(getDisableWarning()));
                mapSymbols.put("disableAutoProlong", new 
Boolean(getDisableAutoProlong()));
                mapSymbols.put("expirationFunction", getExpirationFunction());
                return mapSymbols;
        }
        
        public void renewSession(IRequestCycle cycle)
        {
                // calling this method via the XTile service will automatically 
renew the session
                // System.out.println("Prolonging session...");
        }
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/XTile.java
  
  Index: XTile.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.ajax;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IActionListener;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.Tapestry;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.services.LinkFactory;
  import org.apache.tapestry.services.ServiceConstants;
  
  /**
   * @author mindbridge
   * @author Paul Green
   * @since 4.0
   */
  public abstract class XTile extends BaseComponent implements IXTile
  {
      public abstract LinkFactory getLinkFactory();
      
      public abstract IActionListener getListener();
      public abstract String getSendName();
      public abstract String getReceiveName();
      public abstract String getErrorName();
      public abstract boolean getDisableCaching();
  
        public void trigger(IRequestCycle cycle) {
          IActionListener listener = getListener();
  
          if (listener == null)
                throw Tapestry.createRequiredParameterException(this, 
"listener");
  
          listener.actionTriggered(this, cycle);
        }
        
        public Map getScriptSymbols()
        {
                Map ret = new HashMap();
                ret.put("sendFunctionName", getSendName());
                ret.put("receiveFunctionName", getReceiveName());
                ret.put("errorFunctionName", getErrorName());
                ret.put("disableCaching", getDisableCaching() ? "true" : null);
  
          Map parameters = new HashMap();
          parameters.put(ServiceConstants.SERVICE, XTileService.SERVICE_NAME);
          parameters.put(ServiceConstants.PAGE, getPage().getPageName());
          parameters.put(ServiceConstants.COMPONENT, getIdPath());
                
                ILink link = 
getLinkFactory().constructLink(getPage().getRequestCycle(), 
                                false, parameters, false);
  
                ret.put("url", link.getURL());
                
                return ret;
        }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/Timeout.jwc
  
  Index: Timeout.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2004, 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE component-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
  
  <component-specification class="org.apache.tapestry.contrib.ajax.Timeout"
      allow-body="no" allow-informal-parameters="no">
      
      <description>
          Displays a message to the user when a certain amount of time remains
          to the expiration of the session.
      </description>
      
      <parameter name="warningTime" default-value="300">
          <description>
              The number of seconds before session expiration when a warning 
message will appear.
          </description>
      </parameter>
      
      <parameter name="autoProlongTime" default-value="900">
          <description>
              The number of seconds before session expiration when the session 
              will be automatically prolonged upon user activity.
          </description>
      </parameter>
      
      <parameter name="warningMessage" default-value="message: warning">
          <description>
              The warning message that will appear when the session is about to 
exipre.
              Here {0} is replaced by the number of minutes that remain until 
expiration and 
              {1} is replaced with the time when the expiration will occur.
          </description>
      </parameter>
      
      <parameter name="expirationMessage" default-value="'Your session has 
expired. Please log in again.'">
          <description>
              The message that will appear when the session exipres and
              the user needs to log in again.
          </description>
      </parameter>
  
      <parameter name="disableWarning" default-value="false">
          <description>
              Do not display a warning message after 'warningTime' seconds.
          </description>
      </parameter>
  
      <parameter name="disableAutoProlong" default-value="false">
          <description>
              Disable the automatic prolonging of a session after 
'autoProlongTime' seconds
              upon user activity.
          </description>
      </parameter>
      
      <parameter name="expirationFunction" default-value="null">
          <description>
              The JavaScript function that will be invoked when the session 
expires.
          </description>
      </parameter>
  
          
      <component id="script" type="Script">
          <binding name="script" 
value="literal:/org/apache/tapestry/contrib/ajax/Timeout.script"/>
          <binding name="symbols" value="scriptSymbols"/>
      </component>
  </component-specification>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/XTile.script
  
  Index: XTile.script
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE script PUBLIC
        "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd";>
  <script>
        <input-symbol key="url" class="java.lang.String"/>
        <input-symbol key="sendFunctionName" class="java.lang.String"/>
        <input-symbol key="receiveFunctionName" class="java.lang.String"/>
        <input-symbol key="errorFunctionName" class="java.lang.String"/>
        <input-symbol key="disableCaching" class="java.lang.String"/>
  
  
        <body>
        function ${sendFunctionName}() 
        {
                var requestObject = getRequest();
                if (!requestObject) {
                        $errorFunctionName();
                        return;
                }
                
            var url = "${url}";
            var arguments = ${sendFunctionName}.arguments;
            var argumentCount = arguments.length;
            for (i = 0; i &lt; argumentCount; i++) {
                url = url + "&amp;sp=" + quoteUrl(arguments[i]);
            }
            
            <if expression="disableCaching != null">
            url = url + "&amp;rand=" + Math.random();
            </if>
        
                requestObject.onreadystatechange = function() {
                        if (requestObject.readyState == 4) {
                                if (requestObject.status == 200) {
                                        var data = extractData(requestObject);
                                        ${receiveFunctionName}(data);
                                }
                                <if expression="errorFunctionName != null">
                                else if ("${errorFunctionName}" = "")
                                        ${errorFunctionName}(requestObject);
                                </if>
                        }
                }
                
            requestObject.open("GET", url, true);
            requestObject.send(null);
        }
        
        <unique>
        <![CDATA[
        function getRequest()
        {
                var xmlhttp=false;
                /[EMAIL PROTECTED] @*/
                /[EMAIL PROTECTED] (@_jscript_version >= 5)
                 try {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                 } catch (e) {
                  try {
                   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                   xmlhttp = false;
                  }
                 }
                @end @*/
                if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                  xmlhttp = new XMLHttpRequest();
                }
                return xmlhttp;
        }
        
        function quoteUrl(text)
        {
                return escape(text).replace(/\+/g, 
'%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
        }
        
        function extractData(response)
        {
                var xml = response.responseXML.documentElement;
                var dataList = new Array();
                if (xml) dataList = xml.getElementsByTagName('sp');
                var dataLen = dataList.length;
                var data = new Array();
                for (i = 0; i < dataLen; i++) {
                        var child = dataList[i].firstChild;
                        if (child)
                                data[i] = child.data;
                        else
                                data[i] = "";
                }
                return data;
        }
        ]]>
        </unique>
        
        </body>
  
  </script>
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/XTile.html
  
  Index: XTile.html
  ===================================================================
  <span jwcid="script"/>
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/ajax/XTile.jwc
  
  Index: XTile.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2004, 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE component-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
  
  <component-specification class="org.apache.tapestry.contrib.ajax.XTile"
      allow-body="no" allow-informal-parameters="no">
      
      <description>
          A component providing the required JavaScript to pass some 
information to the server
          and receive its response without reloading the page (Ajax)
      </description>
      
      <parameter name="listener" required="yes">
          <description>
              The listener that will be invoked when the Javascript function 
with the given name is invoked.
              Any parameters passed to the send function will be available from 
cycle.getServiceParameters(). 
              In addition, the listener can perform 
cycle.setServiceParameters() to pass an array of
              strings to the JavaScript receive function.
          </description>
      </parameter>
      
      <parameter name="sendName" required="yes">
          <description>
              The name of the JavaScript function that the script will define 
to allow the application
              to send information to the server.
          </description>
      </parameter>
      
      <parameter name="receiveName" required="yes">
          <description>
              The name of the JavaScript function that the script will call to 
allow the application
              to receive information from the server some time after the send 
function has been invoked.
          </description>
      </parameter>
      
      <parameter name="errorName" default-value="null">
          <description>
              The name of the JavaScript function that the script will call to 
indicate that
              an error has occurred while sending the information to the server.
          </description>
      </parameter>
      
      <parameter name="disableCaching" default-value="false">
          <description>
              Some browsers cache repeated requests that have identical URLs.
              Pass 'true' to this parameter to disable caching by making the 
URLs unique.
          </description>
      </parameter>
      
      <component id="script" type="Script">
          <binding name="script" 
value="'/org/apache/tapestry/contrib/ajax/XTile.script'"/>
          <binding name="symbols" value="scriptSymbols"/>
      </component>
  
      <inject property="linkFactory" object="infrastructure:linkFactory"/>
          
  </component-specification>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlledCheckbox.html
  
  Index: ControlledCheckbox.html
  ===================================================================
  <!-- generated by Spindle, http://spindle.sourceforge.net -->
  
  <span jwcid="$content$">
        <span jwcid="checkbox"/>
  </span>
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlCheckbox.html
  
  Index: ControlCheckbox.html
  ===================================================================
  <!-- generated by Spindle, http://spindle.sourceforge.net -->
  
  <span jwcid="$content$">
        <input jwcid="any" type="checkbox" 
onclick="ognl:checkboxGroup.functionName + '(this.checked)'"/>
  </span>
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlCheckbox.java
  
  Index: ControlCheckbox.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.form.checkboxes;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IRequestCycle;
  
  /**
   * @author mb
   * @since 4.0
  */
  public abstract class ControlCheckbox extends BaseComponent
  {
      public abstract CheckboxGroup getGroup();
      
      public CheckboxGroup getCheckboxGroup()
      {
          CheckboxGroup group = getGroup();
          if (group == null) {
              IRequestCycle cycle = getPage().getRequestCycle();
              group = (CheckboxGroup) 
cycle.getAttribute(CheckboxGroup.CHECKBOX_GROUP_ATTRIBUTE);
          }
          if (group == null)
              throw new ApplicationRuntimeException("The component " + 
getExtendedId() + " must be wrapped by a CheckboxGroup or the 'group' parameter 
must be set.");
  
          return group;
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlledCheckbox.jwc
  
  Index: ControlledCheckbox.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2004, 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE component-specification
        PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
  
  <component-specification 
class="org.apache.tapestry.contrib.form.checkboxes.ControlledCheckbox" 
allow-body="no" allow-informal-parameters="yes">
  
      <description>
          A checkbox whose state may be controlled by other checkboxes using 
JavaScript.
          The checkbox rendered by this component may be automatically selected 
or deselected
          by a ControlCheckbox within the same group.
      </description>
      
      <parameter name="value" required="yes"/>
      <parameter name="disabled" required="no"/>
  
      <parameter name="group" default-value="null">
          <description>
              This is an optional parameter. If provided, it specifies the 
CheckboxGroup
              this component belongs to. If it is not specified, then the 
component is a
              a part of the CheckboxGroup that wraps it.
              Please note that if this parameter is used, then the 
CheckboxGroup it refers to 
              must either enclose the current component, or must be defined 
after it.
          </description>
      </parameter>
          
      <component id="checkbox" type="Checkbox" 
inherit-informal-parameters="yes">
          <inherited-binding name="value" parameter-name="value"/>
          <inherited-binding name="disabled" parameter-name="disabled"/>
      </component>
      
  </component-specification>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/CheckboxGroup.jwc
  
  Index: CheckboxGroup.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2004, 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE component-specification
        PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
  
  <component-specification 
class="org.apache.tapestry.contrib.form.checkboxes.CheckboxGroup" 
allow-body="yes" allow-informal-parameters="no">
      
      <description>
          A component defining a group of checkboxes that will be controlled 
together.
          Typically the ControlCheckbox and ControlledCheckbox components are 
placed
          in the body of this component.
      </description>
      
      <component id="script" type="Script">
          <binding name="script" 
value="'/org/apache/tapestry/contrib/form/checkboxes/CheckboxGroup.script'"/>
          <binding name="functionName" value="functionName"/>
          <binding name="checkboxNames" value="checkboxNames"/>
      </component>
      
      <property name="checkboxNames" initial-value="new java.util.ArrayList()"/>
      <property name="functionName"/>
      
  </component-specification>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/CheckboxGroup.java
  
  Index: CheckboxGroup.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.form.checkboxes;
  
  import java.util.Collection;
  
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IMarkupWriter;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.PageRenderSupport;
  import org.apache.tapestry.TapestryUtils;
  
  /**
   * @author mb
   * @since 4.0
   */
  public abstract class CheckboxGroup extends BaseComponent
  {
      public final static String CHECKBOX_GROUP_ATTRIBUTE = 
"org.apache.tapestry.contrib.form.CheckboxGroup";
  
      public abstract Collection getCheckboxNames();
      public abstract String getFunctionName();
      public abstract void setFunctionName(String functionName);    
  
      public void registerControlledCheckbox(ControlledCheckbox checkbox)
      {
        String name = checkbox.getCheckboxName();
        String form = checkbox.getForm().getName();
          getCheckboxNames().add(form + "." + name);
      }
      
      /**
       * @see 
org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter,
 org.apache.tapestry.IRequestCycle)
       */
      protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
      {
          Object objOtherGroup = cycle.getAttribute(CHECKBOX_GROUP_ATTRIBUTE);
          cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, this);
          
          initialize(cycle);
          
          super.renderComponent(writer, cycle);
  
          // clear the registered checkbox names after rendering
          // allows the component to be used in cycles
          getCheckboxNames().clear();
  
          cycle.setAttribute(CHECKBOX_GROUP_ATTRIBUTE, objOtherGroup);
      }
  
      private void initialize(IRequestCycle cycle)
      {
          String functionName = "setCheckboxGroup";
  
          if (!cycle.isRewinding()) {
                PageRenderSupport body = 
TapestryUtils.getPageRenderSupport(cycle, this);
                if (body != null)
                    functionName = body.getUniqueString("setCheckboxGroup");
          }
          
          setFunctionName(functionName);
      }
      
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlledCheckbox.java
  
  Index: ControlledCheckbox.java
  ===================================================================
  //Copyright 2004 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.form.checkboxes;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.tapestry.BaseComponent;
  import org.apache.tapestry.IForm;
  import org.apache.tapestry.IMarkupWriter;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.form.Checkbox;
  
  /**
   * @author mb
   * @since 4.0
   */
  public abstract class ControlledCheckbox extends BaseComponent
  {
      public abstract CheckboxGroup getGroup();
      
      public String getCheckboxName()
      {
          Checkbox checkbox = (Checkbox) getComponent("checkbox");
          String name = checkbox.getName();
          return name;
      }
      
      public IForm getForm()
      {
        Checkbox checkbox = (Checkbox) getComponent("checkbox");
        IForm form = checkbox.getForm();
        return form;
      }
      
      /**
       * @see 
org.apache.tapestry.BaseComponent#renderComponent(org.apache.tapestry.IMarkupWriter,
 org.apache.tapestry.IRequestCycle)
       */
      protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
      {
          super.renderComponent(writer, cycle);
          
          registerCheckbox();
      }
  
      protected void registerCheckbox()
      {
          getCheckboxGroup().registerControlledCheckbox(this);
      }
      
      public CheckboxGroup getCheckboxGroup()
      {
          CheckboxGroup group = getGroup();
          if (group == null) {
              IRequestCycle cycle = getPage().getRequestCycle();
              group = (CheckboxGroup) 
cycle.getAttribute(CheckboxGroup.CHECKBOX_GROUP_ATTRIBUTE);
          }
          if (group == null)
              throw new ApplicationRuntimeException("The component " + 
getExtendedId() + " must be wrapped by a CheckboxGroup or the 'group' parameter 
must be set.");
  
          return group;
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/ControlCheckbox.jwc
  
  Index: ControlCheckbox.jwc
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2004, 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE component-specification
        PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
  
  <component-specification 
class="org.apache.tapestry.contrib.form.checkboxes.ControlCheckbox" 
allow-body="no" allow-informal-parameters="yes">
      
      <description>
          Selecting or deselecting this checkbox will automatically select or 
deselect 
          all controlled checkboxes in the checkbox group.
      </description>
      
      <parameter name="group" default-value="null">
          <description>
              This is an optional parameter. If provided, it specifies the 
CheckboxGroup
              this component belongs to. If it is not specified, then the 
component is a
              a part of the CheckboxGroup that wraps it.
              Please note that if this parameter is used, then the 
CheckboxGroup it refers to 
              must either enclose the current component, or must be defined 
after it.
          </description>
      </parameter>
      
      <reserved-parameter name="type"/>
      <reserved-parameter name="onclick"/>
      
      <component id="any" type="Any" inherit-informal-parameters="yes"/>
      
  </component-specification>
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/CheckboxGroup.script
  
  Index: CheckboxGroup.script
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     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
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE script PUBLIC
        "-//Howard Lewis Ship//Tapestry Script 1.2//EN"
        "http://tapestry.sf.net/dtd/Script_1_2.dtd";>
    
  <script>
  
  <input-symbol key="functionName" class="java.lang.String" required="yes"/>
  <input-symbol key="checkboxNames" class="java.util.Collection" 
required="yes"/>
  
  <body>
  function ${functionName}(value) {
        <foreach key="checkboxName" expression="checkboxNames">
                document.forms.${checkboxName}.checked=value;
        </foreach>
  }
  </body>
  
  </script>
  
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/form/checkboxes/CheckboxGroup.html
  
  Index: CheckboxGroup.html
  ===================================================================
  <!-- generated by Spindle, http://spindle.sourceforge.net -->
  
  <span jwcid="$content$">
        <span jwcid="@RenderBody"/>
      <span jwcid="script"/>
  </span>
  
  
  1.6       +6 -0      
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/Contrib.library
  
  Index: Contrib.library
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/Contrib.library,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Contrib.library   6 Jan 2005 02:17:33 -0000       1.5
  +++ Contrib.library   14 Aug 2005 14:12:56 -0000      1.6
  @@ -57,4 +57,10 @@
       
specification-path="tree/components/table/TreeTableNodeViewDelegator.jwc"/>
     <page name="TreeNodeViewPage" 
specification-path="tree/components/TreeNodeViewPage.page"/>
     <page name="TreeTableNodeViewPage" 
specification-path="tree/components/table/TreeTableNodeViewPage.page"/>
  +  
  +  <component-type type="CheckboxGroup" 
specification-path="form/checkboxes/CheckboxGroup.jwc"/>
  +  <component-type type="ControlCheckbox" 
specification-path="form/checkboxes/ControlCheckbox.jwc"/>
  +  <component-type type="ControlledCheckbox" 
specification-path="form/checkboxes/ControlledCheckbox.jwc"/>
  +  <component-type type="XTile" specification-path="ajax/XTile.jwc"/>
  +  <component-type type="Timeout" specification-path="ajax/Timeout.jwc"/>
   </library-specification>
  \ No newline at end of file
  
  
  
  1.1                  
jakarta-tapestry/contrib/src/java/org/apache/tapestry/contrib/link/FormLinkRenderer.java
  
  Index: FormLinkRenderer.java
  ===================================================================
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // 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
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.contrib.link;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.tapestry.IMarkupWriter;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.Tapestry;
  import org.apache.tapestry.components.ILinkComponent;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.html.Body;
  import org.apache.tapestry.link.DefaultLinkRenderer;
  import org.apache.tapestry.link.ILinkRenderer;
  
  /**
   * A link renderer that ensures that the generated link uses POST instead of 
GET request and 
   * is therefore no longer limited in size. 
   * <p>
   * Theoretically, browsers should support very long URLs,
   * but in practice they often start behaving strangely if the URLs are more 
than 256 characters.
   * This renderer uses JavaScript to generate forms containing the requested 
link parameters and 
   * then "post" them when the link is selected.  
   * As a result, the data is sent to the server using a POST request with a 
very short URL 
   * and there is no longer a limitation in the size of the parameters.    
   * <p>
   * In short, simply add the following parameter to your 
<code>DirectLink</code>, 
   * <code>ExternalLink</code>, or other such link components: 
   * <pre>
   * renderer="ognl: @[EMAIL PROTECTED]"
   * </pre>
   * and they will automatically start using POST rather than GET requests. 
Their parameters
   * will no longer be limited in size.     
   * 
   * @author mb
   * @since 4.0
   */
  public class FormLinkRenderer extends DefaultLinkRenderer
  {
        /**
         *      A public singleton instance of the 
<code>FormLinkRenderer</code>.
         *  <p>
         *  Since the <code>FormLinkRenderer</code> is stateless, this instance
         *  can serve all links within your application without interference.
         */
        public final static ILinkRenderer RENDERER = new FormLinkRenderer();
  
        public void renderLink(IMarkupWriter writer, IRequestCycle cycle, 
ILinkComponent linkComponent) {
          IMarkupWriter wrappedWriter = null;
  
          if (cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME) != 
null)
              throw new ApplicationRuntimeException(
                  Tapestry.getMessage("AbstractLinkComponent.no-nesting"),
                  linkComponent,
                  null,
                  null);
  
          cycle.setAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME, 
linkComponent);
  
          String actionId = cycle.getNextActionId();
          String formName = "LinkForm" + actionId;
          
                boolean hasBody = getHasBody();
  
          boolean disabled = linkComponent.isDisabled();
  
          if (!disabled && !cycle.isRewinding())
          {
              ILink l = linkComponent.getLink(cycle);
              String anchor = linkComponent.getAnchor();
  
              Body body = Body.get(cycle);
  
              if (body == null)
                    throw new ApplicationRuntimeException(
                        Tapestry.format("must-be-contained-by-body", 
"FormLinkRenderer"),
                        this,
                        null,
                        null);
  
              String function = generateFormFunction(formName, l, anchor);
              body.addBodyScript(function);
              
              if (hasBody)
                  writer.begin(getElement());
              else
                  writer.beginEmpty(getElement());
  
              writer.attribute(getUrlAttribute(), "javascript: document." + 
formName + ".submit();");
  
              beforeBodyRender(writer, cycle, linkComponent);
  
              // Allow the wrapped components a chance to render.
              // Along the way, they may interact with this component
              // and cause the name variable to get set.
  
              wrappedWriter = writer.getNestedWriter();
          }
          else
              wrappedWriter = writer;
  
          if (hasBody)
              linkComponent.renderBody(wrappedWriter, cycle);
  
          if (!disabled && !cycle.isRewinding())
          {
              afterBodyRender(writer, cycle, linkComponent);
  
              linkComponent.renderAdditionalAttributes(writer, cycle);
  
              if (hasBody)
              {
                  wrappedWriter.close();
  
                  // Close the <element> tag
  
                  writer.end();
              }
              else
                  writer.closeTag();
          }
  
          cycle.removeAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);
                
        }
        
        private String generateFormFunction(String formName, ILink link, String 
anchor)
        {
                String[] parameterNames = link.getParameterNames();
                
                StringBuffer buf = new StringBuffer();
                buf.append("function prepare" + formName + "() {\n");
  
                buf.append("  var html = \"\";\n");
                buf.append("  html += \"<div style='position: absolute'>\";\n");
                
                String url = link.getURL(anchor, false);
                buf.append("  html += \"<form name='" + formName + "' 
method='post' action='" + url + "'>\";\n");
  
                for (int i = 0; i < parameterNames.length; i++) {
                        String parameter = parameterNames[i];
                        String[] values = link.getParameterValues(parameter);
                        for (int j = 0; j < values.length; j++) {
                                String value = values[j];
                                buf.append("  html += \"<input type='hidden' 
name='" + parameter + "' value='" + value + "'/>\";\n");
                        }
                }
                buf.append("  html += \"<\" + \"/form>\";\n");
                buf.append("  html += \"<\" + \"/div>\";\n");
                buf.append("  document.write(html);\n");
                buf.append("}\n");
                
                buf.append("prepare" + formName + "();\n\n");
  
                return buf.toString();
        }
        
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to