6 Replies Latest reply: Jul 1, 2013 2:03 AM by Nelash Jindal RSS

    How to add a Submit Button to a typeless template to refresh itself

    user621094

      Hi Experts,

       

      I am trying to figure out how we can run a simple JSP which takes input from the user and presents the results in WebCenter Sites. I wrote a simple WebService client application which shows the currency conversion rate with the input of from and to currency. It works as a regular application. I wanted to accomplish the same in WebCenter Sites. I did the following..

       

      1) I have copied the jar file to <InstallDir>/App_Server\apache-tomcat-6.0.32\webapps\cs\WEB-INF\lib directory.

      2) Created a typeless template(TestNormal02.jsp) using eclipse.

      3) Replaced the code eclipse created in the JSP with the tested JSP code from JDev.

      4) Modified the form action in two attempts

      <form action="TestNormal02.jsp" method="POST">

      <form action="http://localhost:8080/cs/Satellite?pagename=avisports/TestNormal02" method="POST">

      5) Synced with Sites

      6) Accessed the page with http://localhost:8080/cs/Satellite?pagename=avisports/TestNormal02

      7) Page renders with input text boxes and submit button.

      8) When I enter the from and to currency and hit submit, It takes me to the sites admin login page.

      9) I have checked the logfile and it shows me the following error..

       

      Can you please help me to resolve this issue? I really appreciate your help.

       

      Thanks & Regards,

      Srini Alavala

       

       

      [2013-06-24 14:42:31,113 UTC] [INFO ] [http-8080-31] [logging.cs.cache.page] Forcing short expire time on pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true. The page had zero length.

      [2013-06-24 14:42:31,114 UTC] [ERROR] [http-8080-31] [logging.cs.cache.page] Unable to add page pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true to cache
      [2013-06-24 14:42:39,294 UTC] [ERROR] [http-8080-31] [logging.cs.auth.request] Bad Request: Invalid Request
      [2013-06-24 14:43:14,857 UTC] [INFO ] [http-8080-37] [logging.cs.cache.page] Forcing short expire time on pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true. The page had zero length.
      [2013-06-24 14:43:14,858 UTC] [ERROR] [http-8080-37] [logging.cs.cache.page] Unable to add page pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true to cache
      [2013-06-24 14:43:21,885 UTC] [ERROR] [http-8080-37] [logging.cs.auth.request] Bad Request: Invalid Request
      [2013-06-24 14:43:41,759 UTC] [INFO ] [http-8080-42] [logging.cs.cache.page] Forcing short expire time on pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true. The page had zero length.
      [2013-06-24 14:43:41,760 UTC] [ERROR] [http-8080-42] [logging.cs.cache.page] Unable to add page pagename=avisports/TestNormal02&rendermode=live&site=avisports&ft_ss=true to cache
      [2013-06-24 14:43:47,478 UTC] [ERROR] [http-8080-32] [logging.cs.auth.request] Bad Request: Invalid Request
        • 1. Re: How to add a Submit Button to a typeless template to refresh itself
          Nelash Jindal

          Hi,

           

          This html form tag doesn't work in webcenter. To submit a form, you have to <sattelite:form/>.

           

          Thanks,

          Nelash jindal

          • 2. Re: How to add a Submit Button to a typeless template to refresh itself
            user621094

            Thanks Nelash. That is helpful. 

             

            Can you please let me know how I can transfer the following into Sites tags to refresh on the same page?

             

             

                    <form action="XXXXXXXXX.jsp" method="POST">

                        <table>

                            <tbody>

                                <tr>

                                <td>

                                        <input type="text" id="toCountry" name="toCountryId"/>

                                </td>

                                <td>

                                        <input type="text" id="fromCountry" name="fromCountryId"/>

                                </td>

                                </tr>

                                <tr>

                                    <td colspan="10" align="left">

                                        <button type="submit">Submit</button>

                                    </td>

                                </tr>

                            </tbody>

                        </table>

                    </form>

            • 3. Re: How to add a Submit Button to a typeless template to refresh itself
              user621094

              Thanks Nelash. That is good to know. Where can I find more details on this. Here is what I am trying to do. Take the input from the customer and set them as bean parameters to invoke the WebService with a submit button. I want to render the results on the same page. Here is the sample. How do I convert the following into Sites tags?

               

               

                      <form action="XXXXXXXXX.jsp" method="POST">

                          <table>

                              <tbody>

                                  <tr>

                                  <td>

                                          <input type="text" id="toCountry" name="toCountryId"/>

                                  </td>

                                  <td>

                                          <input type="text" id="fromCountry" name="fromCountryId"/>

                                  </td>

                                  </tr>

                                  <tr>

                                      <td colspan="10" align="left">

                                          <button type="submit">Submit</button>

                                      </td>

                                  </tr>

                              </tbody>

                          </table>

                      </form>

               

                  <jsp:setProperty property="toCountry" name="conversion" value="${param.toCountryId}" />
                 
                  <jsp:setProperty property="fromCountry" name="conversion" value="${param.fromCountryId}"/>
              • 4. Re: How to add a Submit Button to a typeless template to refresh itself
                user621094

                I am able to find an answer after few hours of struggle. Here is the working version of the <satellite:form>.

                 

                    <satellite:form>
                                <input type="hidden" name="pagename" value="avisports/TestNormal02"/>
                                     <input type="text" id="toCountry" name="toCountryId"/>
                                     <input type="text" id="fromCountry" name="fromCountryId"/>
                                     <input type="submit" name="Submit" value="Submit"/>
                    </satellite:form>

                 

                I had to use a different JSP to display the results. Second JSP reads them as request parameters as follows..

                You can see parameters in the URL as pagename=avisports%2FTestNormal02&toCountryId=USD&fromCountryId=EUR&Submit=Submit and we can access them as follows:

                toCountryId=<ics:getvar name="toCountryId"/>
                fromCountryId=<ics:getvar name="fromCountryId"/>

                 

                I hope this helps others..

                 

                Srini

                • 5. Re: How to add a Submit Button to a typeless template to refresh itself
                  BSR

                  Hi,

                   

                  How do I use this <satellite:form> tag, when called(recipient) element is a Servlet ???

                   

                  Thanks!

                  BSR

                  • 6. Re: How to add a Submit Button to a typeless template to refresh itself
                    Nelash Jindal

                    Hi BSR,

                     

                    You can use a normal html form tag for calling a servlet. This <satellite:form> tag is used when your called element is CSElement or Template.

                     

                    For calling a normal servlet, you have to make entry for this servlet in <SERVER_HOME>\webapps\cs\WEB_INF\web.xml and place this servlet file in <SERVER_HOME>\webapps\cs\WEB_INF\classes folder.

                     

                    Hope this helps.

                     

                    Thanks,

                    Nelash Jindal