Jsf form tag

why does the tld say that the form tag can specify an "action" attribute?
When I don't specify an "action" attribute, jsf creates one for me.
What are the rules for generating this default "action" url?
What if I do specify an "action" attribute for a form?
Is the application handler not called then?

You cannot; allowing this would be antithetical to the nature of JSF, where the UIComponents that created the output of the page (or the Renderers they delegated to) are the only objects that can interpret the response.
If you need another servlet to be involved in processing incoming parameters - like reusing a login servlet - I'd recommend writing a normal JSF page, letting JSF handle postback, but then write an action listener that:
(1) grabs values out of your managed bean
(2) forwards the request to your servlet, explicitly adding those values as query parameters with the keys that the servlet expects
(3) Calls FacesContext.responseComplete()
-- Adam Winer

Similar Messages

  • Question about creating Custom JSF form tag and renderer

    Is it possible to build a custom form tag in JSF and have it replace the standard jsf form tag. Are there any potential issues with child forms or anything else.
    I created the following
    - custom form component class that extends javax.faces.component.UIForm (the only changes I made was to change the value of the COMPONENT_TYPE attribute and change the value for renderer type)
    - custom form renderer class that extends HtmlBasicRenderer and I made changes to the encodebegin method and encrypt the value of the id and action url)
    - custom form tag class that extends UIComponentELTag ( I did not make any changes here)
    - tld for my custom form tag
    - created an entry in faces-config.xml of my web-app for my custom form tag
    Are there any issues with the above.
    Is there something I should do in addition.

    In theory you should be fine. Some of the open source libraries either swap out the renderer for the standard h:form component or supply their own form components. You could look at their code for reference if need be.

  • More than one h:form tag?

    Hi, I have my pages setup with a header and footer page. So that each page does this:
    home.jsp:
    <%@ include file="/includes/header.jsp" %>
    <%@ include file="/includes/footer.jsp" %>Now, both the header.jsp and footer.jsp pages use h:commandLink tags wrapped inside h:form tags. Like:
    <h:form>
        <h:commandLink id="myLink" action="myLink" title="#{resources.myLabel}" >
            <h:outputText value="#{resources.myLabel}" />
        </h:commandLink>
    </h:form>The problem is that only the ones defined in the header page work. If I remove the h:form and all h:commandLink tags from the header page then the ones in the footer page work. Seems like if you setup your pages like this that only the first h:form block works. Whats the deal with that? Not sure if its because I'm mixing JSP with JSF and if there are problems with that but seems like making a header and footer page included on all pages is a legitimate approach, am I missing something?
    Thanks for any help,
    Mike

    After looking at my JavaScript console, I get the following JavaScript error when I click on a link in the second form:
    Error: document.forms['Header:two']['Header:two:_idcl'] has no properties
    I looked this bug up in the Bug Database and found it (5055795). It says its fixed, but unfortunately doesn't say what version its fixed in or where/when the fix is available. Does anybody have any clue where/when this fix will be available?
    Thanks.

  • h:commandLink requires form tag

    Hi,
    I do not know where to find an answer. If you could help me with that, I would be very grateful to you as I have encountered this problem many times.
    The jsf programs that have h:commandLink in it works fine as an individual component. In reality, we develop application with a left hand side for menu and the right hand side for content display. We have a index.jsp (main) page with all the and <h:form> tags. Based on the menu selected, the content page will be displayed. The content page will have only the tags for content display and not the and <h:form> tags.
    If the content page has a h:commandLink, it expects a <h:form> tag around it. If we include <h:form> tag in the content page, then it becomes a nested form as the index.jsp has already a <h:form> tag and the content page does not work as expected.
    I am unaware of how to handle this situation if we have a h:commandLink/h:commandButton tag in the content page .. and the index.jsp has already 'form' tag in it.
    I get the error message next to h:commandLink stating "This tag must be nested within
    tag". Even though the main page has the form tag, this content page with the h:commandLink expects it. Not sure how to handle it.. Please suggest
    Can you please let me know..
    Thanks a lot
    Aish

    Hi,
    Yes. I get this error message on the IDE (I am using IBM RAD 7). As soon as I type the code, The ide displays the error message.
    As you have suggested, I ran my code ignoring the error and the commandlink worked fine.
    Thanks a lot for resolving my problem which has been for sometime.
    Aishu

  • What happens to regular input controls within JSF form?

    What does JSF do with plain HTML/XHTML input controls contained inside a JSF form? Considering an HTML form gets rendered I would image that the values of the plain HTML control gets submitted. Does JSF just trash them?

    Anthony_Smith wrote:
    That's what I thought would happen. My request maps are returning empty though (calling ExternalContext#getRequestParameterValuesMap()). Just in case I'm being misunderstood I'm going to try to explain my question again.
    I have a JSF form but I'm trying to stick regular input tags in them. I haven't had any luck getting them back through the request methods in ExternalContext. It's as if they're not getting submitted or JSF is just throwing them out. Any ideas?If the request parameter map was empty, JSF wouldn't be able to handle a postback. So, we arrive at one of the following possibilities:
    1) The request is not a postback, but a simple parameterless GET. But you indicate a form is being submitted, seemingly discounting this possibility. However, if you are using a redirect, it is not an uncommon mistake to forget that and assume that everything from the previous request will be available during the redirected request, which it is not.
    2) Your JSF implementation is completely broken.

  • Need JSF fuego tag libraries

    Hi,
    In our project we are going to use JSF for UI. For JSP , there is online documentation for fuego tag libraries. But there is no documentation for JSF tag libraries. Only the one example available with Studio installation. But we have requirements like calling BPM Object methods in UI. But since the syntax is not available , we are not abel to proceed with development. It will be very helpful if some one provides details of JSF fuego tag libraries
    Thanks,
    Bharath

    Hi All,
    This requirement is a sure stopper for our project. I need some documentation or examples for "JSF fuego tag libraries". Online documentation is available for "JSP fuego tag libraries" at Link: [http://download.oracle.com/docs/cd/E13154_01/bpm/docs65/taglib/index.html]. The tags like <f:invoke> are working properly in JSP pages. I tried to use the same in JSF pages, but they are giving error.
    The tags is different in JSF and JSP. For e.g.. to post the results back to bpm engine in JSP we use <f:postResult> in the action attribute of form tag whereas for JSF it is "returnToFuego" which has to be added in the action attribute of button.
    Please guide me with some examples.
    Thanks,
    Bharath

  • How do I use dynamic JSP vars in a form tag with implicit sessions?

    I'm using iAS 6 SP4 and 'lite' sessions w/ sticky LB on Win2K for development and need to use a dynamic variable (via an = scriptlet) to specify the URL a form tag's ACTION method posts to. The implicit URL session encoding attempts to add the hidden input tags to the form but part of it is getting cut off. If I remove the dynamic var scriptlet from the form tag it works fine. How can I use dynamic vars and implicit URL session encoding?
    Here's my code sample:
    <FORM NAME='Create' METHOD='POST' ACTION='<%= servletRootStr %>CreateServlet' TARGET='_top'>
    Output is:
    <FORM NAME='Create' METHOD='POST' ACTION='http://my.server.com/NASApp/WebStuffApp/Create' TARGET='_top'>T NAME="GXHC_gx_session_id_" TYPE="HIDDEN" VALUE="GXLiteSessionID--8351372849698357580" ></INPUT><INPUT NAME="GXHC_GX_jst" TYPE="HIDDEN" VALUE="d692bc3d662d6164" ></INPUT>
    Because the <INPUT> tagon the first session var is cut off, up to the T, the page obviously fails. Can this be fixed with a config setting, or is it a bug in iPlanet??

    Thanks for helping me Anurag.
    The problem I tried to solve was that I want the result from my service methods
    in XML format. I thought a callback/polling was the best alternative, am I right?
    Since the callback option doesn´t work I will try to poll the service.
    Are there any other options for solving my problem??
    Thanks again!!
    /A
    "Anurag Pareek" <[email protected]> wrote:
    >
    Andrej,
    I guess you are trying to invoke a Webservice which defines a callback
    method
    from a JSP, and want the JSP to handle the callback made by the webservice.
    For a client to be able to handle a callback made by a Webservice, it
    has to be
    a web service in itself.
    Even some web service tools do not support 'Solicit responses' and hence
    they
    would not generate handlers for the callback methods by default. You
    can download
    a callback WSDL in such cases and implement it on the client side. The
    server
    side web service will then callback to that webservice.
    The other option to callbacks is to use polling methods. This can be
    done from
    any client such as Java client/ JSP client or a .NET client.
    Hope this helps. Let me know if you have any further questions.
    Regards,
    Anurag
    "Andrej" <[email protected]> wrote:
    I´ve tried this but with no success..
    How do I recieve the data in a servlet/JSP-page?
    Thanks.

  • How to change the fields in a JSF form based on a URL parameter

    I am trying to build a generic JSF form of parameters which I want to dynamically change (i.e.
    change which field is visible, what the label text should be, etc) based on a URL parameter.
    I can set the fields using logic in the backing bean as an action on a command button pressed.
    But how do I do it based on the URL parameter ? I can retrieve the URL parameter but I
    don't know where to put (or hook) the Java code to do this initialization prior to
    the page being rendered for the first time.
    The fields in the JSF is being configured dynamically using a database table.
    BTW I am using Jdeveloper 10.1.3.5
    Thanks
    CK

    Thanks. I decided to set a Session bean to store the value of the URL parameter (if it is set)
    and then to use the session bean to initialize the attributes of the fields on the JSF Page.
    There also seems to be some caching of the inputText fields (i.e. it reverts back to the first
    initialized value) even though I tried to change it using the URL parameter in the requestScope
    backing bean. So, setting the values into the Session bean and retrieving it back from there
    seems to be more reliable.

  • Help needed with Myfaces - tomahawk t:panelTabbedPane form tag iserted wh

    when i Use tomahawk <t:panelTabbedPane> component, during rendering stage. its atomatically inserts <form> tag around it.
    Is there any way to avoid this <form tag. because, I am using 3 tab column, and each tab has got its own form tag.
    so in that case. there is <form> inside <form>, thats giving errors when using some javascript function with this..
    is there any solution for this

    Hi,
    Could you please tell us if you are using Sun Java Studio Creator for building your web application.
    RK

  • How to use Direct Access URL in the FORM tag

    I want to substitute the pageid url (/servlet/page?_pageid=161&_dad=portal30&_schema=PORTAL30) with the direct access urls (pls/portal30/url/page/my_page) to address the pageid conflict between development server and production server.
    It works perfectly fine in the redirection code such as:
    self.location.href="/pls/portal30/url/page/next_page". But I got "Page can not be found" error message when I use it in the <FORM> tag:
    <FORM ACTION="/pls/portal30/url/page/next_page" METHOD="POST" NAME="my_form">
    Does anyone out there know how to use the direct access url inside the <FORM> tag? I am trying not to write a bunch of code just to retrieve and insert the pageid at the run time.
    Thanks in advance.
    Arthur

    Use condition. If you are validating a record, just out the desired check in the condition field for that specific item.
    Thanks
    Nagamohan

  • Control 'ctl00_SPWebPartManager1_g_d4fb972b_26ec_4065_9c89_80b51b384492_gvwikireport' of type 'GridView' must be placed inside a form tag with runat=server.

    Hi,
    I have written code for 'Export To Excel' in the visual web part as below
    //ascx file    
    <table>
        <tr>
            <td>From Date:</td>
            <td><SharePoint:DateTimeControl ID="dtFromDate" runat="server" DateOnly="True" /></td>
        </tr>
        <tr>
            <td>To Date:</td>
            <td><SharePoint:DateTimeControl ID="dtToDate" runat="server" DateOnly="True" TimeOnly="False" /></td>
        </tr>
        <tr>
          <td>Report Type:<asp:DropDownList ID="ddlreporttype" runat="server"><asp:ListItem>Consolidated</asp:ListItem><asp:ListItem>Question Wise</asp:ListItem></asp:DropDownList></td>
            <td>
                <br />               
                <asp:GridView ID="gvwikireport" runat="server">
                </asp:GridView>                   
            </td>
        </tr>   
        <tr>
            <td><asp:Button ID="btnExportToExcel" runat="server" Text="Export To Excel" OnClick="btnExportToExcel_Click"/></td>
        </tr>  
        </table>
    //cs file
    protected void Page_Load(object sender, EventArgs e)
                if (!Page.IsPostBack)
                    BindGridview();
    private void BindGridview()
                DataTable dt = new DataTable();
                dt.Columns.Add("UserId", typeof(Int32));
                dt.Columns.Add("UserName", typeof(string));
                dt.Columns.Add("Education", typeof(string));
                dt.Columns.Add("Location", typeof(string));            
                dt.Rows.Add(1, "SureshDasari", "B.Tech", "Chennai");
                dt.Rows.Add(2, "MadhavSai", "MBA", "Nagpur");
                dt.Rows.Add(3, "MaheshDasari", "B.Tech", "Nuzividu");
                dt.Rows.Add(4, "Rohini", "MSC", "Chennai");
                dt.Rows.Add(5, "Mahendra", "CA", "Guntur");
                dt.Rows.Add(6, "Honey", "B.Tech", "Nagpur");
                gvwikireport.DataSource = dt;
                gvwikireport.DataBind();
    protected void btnExportToExcel_Click(object sender, EventArgs e)
                Page.Response.ClearContent();
                Page.Response.Buffer = true;
                Page.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "WikiReport.xls"));
                Page.Response.ContentType = "application/ms-excel";
                StringWriter sw = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                gvwikireport.AllowPaging = false;
                BindGridview();
                //Change the Header Row back to white color
                gvwikireport.HeaderRow.Style.Add("background-color", "#FFFFFF");
                //Applying stlye to gridview header cells
                for (int i = 0; i < gvwikireport.HeaderRow.Cells.Count; i++)
                    gvwikireport.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
                gvwikireport.RenderControl(htw);
                Page.Response.Write(sw.ToString());
                Page.Response.End();            
    But after clicking the 'Export To Excel' button i am getting the below error
    Control 'ctl00_SPWebPartManager1_g_d4fb972b_26ec_4065_9c89_80b51b384492_gvwikireport' of type 'GridView' must be placed inside a form tag with runat=server.
    In case if i am modifying the code as below I am getting error as 'page can have only one server tag'.
    <form id="frmgrdview" runat="server">
     <asp:GridView ID="gvwikireport" runat="server">
                 </asp:GridView></form>
    So please share your ideas/thoughts on the same.
    Regards,
    Sudheer 
    Thanks & Regards, Sudheer

    Hi,
    According to your post, my understanding is that you fail to export to excel.
    I create a demo as below, it works well.
    <table>
    <tr>
    <td>
    <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
    </td>
    <td>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>
    <asp:GridView ID="gvwikireport" runat="server">
    </asp:GridView>
    </td>
    <td>
    <br />
    <asp:Button ID="btnExportToExcel" runat="server"
    onclick="btnExportToExcel_Click" Text="Export to excel" />
    </td>
    </tr>
    </table>
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Data;
    using System.IO;
    namespace Export_to_Excel.VisualWebPart1
    public partial class VisualWebPart1UserControl : UserControl
    protected void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)
    BindGridview();
    private void BindGridview()
    DataTable dt = new DataTable();
    dt.Columns.Add("UserId", typeof(Int32));
    dt.Columns.Add("UserName", typeof(string));
    dt.Columns.Add("Education", typeof(string));
    dt.Columns.Add("Location", typeof(string));
    dt.Rows.Add(1, "SureshDasari", "B.Tech", "Chennai");
    dt.Rows.Add(2, "MadhavSai", "MBA", "Nagpur");
    dt.Rows.Add(3, "MaheshDasari", "B.Tech", "Nuzividu");
    dt.Rows.Add(4, "Rohini", "MSC", "Chennai");
    dt.Rows.Add(5, "Mahendra", "CA", "Guntur");
    dt.Rows.Add(6, "Honey", "B.Tech", "Nagpur");
    gvwikireport.DataSource = dt;
    gvwikireport.DataBind();
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    Page.Response.ClearContent();
    Page.Response.Buffer = true;
    Page.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "WikiReport.xls"));
    Page.Response.ContentType = "application/Excel";
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    gvwikireport.AllowPaging = false;
    BindGridview();
    //Change the Header Row back to white color
    gvwikireport.HeaderRow.Style.Add("background-color", "#FFFFFF");
    //Applying stlye to gridview header cells
    for (int i = 0; i < gvwikireport.HeaderRow.Cells.Count; i++)
    gvwikireport.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
    gvwikireport.RenderControl(htw);
    Page.Response.Write(sw.ToString());
    Page.Response.End();
    The result is as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Is there a workaround for inserting form tags?

    Long time ago some developers found some bugs in the SWING class. The bug seems to appear when an HTML page pasted in the browser. Then the <form>-tags are disappeared while they can be found before pasting the HTML into the browser.
    This is my code so far:
    int pos = 0;
    int i = 0;
    body = getBodyContent();
    JspWriter out = body.getEnclosingWriter();
    HTMLKit = new HTMLEditorKit();
    try {
    out.println(body.getString());
    body.clearBody();
    String theQuery = "http://documentum1.europe.intranet/Docu2store:/list.htm?objectID=" + folderid + "&framed=yes|0&docstart=" + docstart;
    try {
    URL aURL = new URL( theQuery );
    URLConnection conn = aURL.openConnection();
    JEditorPane HTMLPane = new JEditorPane();
    HTMLPane.setContentType("text/html");
    HTMLPane.setPage(aURL);
    HTMLPane.read( new InputStreamReader( conn.getInputStream() ), "Docu2store" );
    //HTMLPane.read( new Reader (conn.getInputStream() ), "Docu2Store" );
    HTMLDoc = (HTMLDocument) HTMLPane.getDocument();
    //HTMLDoc.setBase(new URL ("http://documentum1.europe.intranet/"));
    // Reading the form
    HTMLDocument.Iterator form = HTMLDoc.getIterator(HTML.Tag.FORM);
    //form.next();
    Enumeration formEnum = form.getAttributes().getAttributeNames();
    out.println (form.getAttributes().getAttributeNames());
    out.println (form.getAttributes().getAttribute(formEnum.nextElement()).toString());
    //form.next();
    //out.println (form.getAttributes().getAttribute(formEnum.nextElement()).toString());
    // Reading the links and replace them
    HTMLDocument.Iterator theLinks = HTMLDoc.getIterator(HTML.Tag.A);
    theLinks.next();
    while (theLinks.isValid()) {
    Enumeration theAttsEnum = theLinks.getAttributes().getAttributeNames();
    String theValue = theLinks.getAttributes().getAttribute(theAttsEnum.nextElement()).toString();
    if (theValue.indexOf("sorting", 0) > 0) {
    i++;
    int pageNum = giveItemUrl("docstart", theValue) + 1;
    int startPosLink = theLinks.getStartOffset();
    int endPosLink = theLinks.getEndOffset();
    int linkLength = endPosLink - startPosLink;
    try {
    HTMLDoc.remove(startPosLink, linkLength);
    String fid = giveItemUrlString("objectID", theValue);
    String docstart = giveItemUrlString("docstart", theValue);
    String sorting = giveItemUrlString("sortingfield", theValue);
    HTMLKit.insertHTML(HTMLDoc, endPosLink - 1, "<a href='main.jsp?fid=" + fid + "&docstart="+docstart+"'>" + Integer.toString(pageNum) + "</a>", 0, 0, HTML.Tag.A);
    } catch (BadLocationException ble) {
    ble.printStackTrace();
    out.println( i + "fout" );
    theLinks.next();
    HTMLPane.write(out);

    Insert HTML via InsertHTML() doesn't work! After writing the HTMLDocument, Java inserts extra <html> tags!

  • Form Tag Issue

    Hi!
    am facing problem while submitting form through DropDown using onChange event!
    Here i have two form tags and two drop down .in first form tag contain one drop down and
    Second form tag contain another Drop down ..
    when i change first drop down it redirects to the page properly, and i chose another drop down it redirect the page which is specified in first form tag,it is not redirect to the page which is specified in second form tag..
    pls give me your suggestion regarding my issue...
    <%
    try{
    Connection con,con1;
        Statement st,st1;
        ResultSet rs,rs1,rs2;
        ResultSetMetaData rsm,rsm1;
        List data=new ArrayList();
        List data1=new ArrayList();
        Iterator itr,itr1;
        String val,val1;
        int i=0;
        String dep[]=new String[100];
        int deplen;
        String dsn="jdbc:odbc:project";
                Class.forName("oracle.jdbc.driver.OracleDriver");
                con=DriverManager.getConnection(dsn,"module7","module7");
                st=con.createStatement();
                rs=st.executeQuery("select collname from college");
                            while(rs.next())
                                data.add(rs.getString(1));
                                i++;
               // rs1=st.executeQuery("select subcode from subject where sem not in '"+session.getAttribute("sem")+"' and dep='"+session.getAttribute("dep")+"' and sem1='"+session.getAttribute("mon1")+"' and currorarrear='Arrear'  order by subcode");
    %>
        <form  name="f1" action="Coll" method="POST" >
            <table align="center" border="0">
                    <tr>
                        <td>Select the College</td>
                        <td>
                            <select  class="red"  name="coll" id="s11" onchange="this.form.submit();">
                            <option value="Select">--------Select--------</option>
                                <%
                                try{
                            for(itr=data.iterator();itr.hasNext();)
                            val=itr.next().toString();
                                //out.print("111");
                            %>
                            <option value="<%=val%>"><%=val%></option>
                            <%}%>
                    </select></td>
                    </tr>
                       </form><%}catch(Exception e){}%>
                    <form name="f2" action="CollDep" method="POST">
    <%try{
        data1=(ArrayList)session.getAttribute("dep");
        if(session.getAttribute("dep").toString()!=null)
        {%>
                   <tr>
                        <td>Select the Department</td>
                        <td><select name="univ" id="arr1" onchange="this.form.submit();">
                           <option>Department</option>
                           <%
                            for(itr=data1.iterator();itr.hasNext();)
                            val=itr.next().toString();
                          %>
                                 <option value=<%=val%>><%=val%></option>
                            <%}%>
    </select></td>
                    </tr></form><%}}catch(Exception e){}%>
            </table>
            <center><input type="submit" value="Submit" name="b1" onclick="" /></center>
    <%
    }catch(Exception e){out.println(e);}
    %>
               

    The [HTML specification|http://www.w3.org/TR/html401/] forbids you to nest <form> elements.
    That said, writing raw Java code in a JSP file is a bad practice. It makes it hard to read as well. Keep business/data logic in Java classes (servlets, DAO's, beans) and use taglibs/EL only in JSP.

  • Error in form tag which calls a javascript function

    Following is the code
    <script type="text/javascript">
    try{
         var variable3=(document.forms[0]).server_Name.value;
         var variable=(document.forms[0]).job_Name.value;
         }catch(err){}
      function returnall()
           var vald2=checkempty();       
           var vald3=checkspace();
           var vald1=checkemail(variable3);
           if(vald2 && vald3 && vald1)
                return true;
           return false;                  
       function checkemail(variable3)
          bcd = document.getElementById('EmailAd');
          var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
          if (!filter.test(bcd.value)&& bcd.value != '')
          document.getElementById('emailvalid').innerHTML = 'Please enter a valid email Address';
             return false;
        function checkempty()
              var abc, bcd, cde, def, efg, fgh, ghi
              abc = document.getElementById('jobn');
              bcd = document.getElementById('EmailAd');
              cde = document.getElementById('pass');
              if (abc.value == ''&& bcd.value == ''&& cde.value == '')
                   document.getElementById('nodata').innerHTML = 'Please enter jobname,Email and Password ';
             else
             if(bcd.value == ''&& cde.value == '')
                       document.getElementById('nodata').innerHTML = 'Email and Password cannot be left blank';
             else
             if(abc.value == '' && cde.value == '')
                       document.getElementById('nodata').innerHTML = 'Job name and Password cannot be left blank';
                else
                if(abc.value == ''&& bcd.value == '')
                     document.getElementById('nodata').innerHTML = 'Job name and Email cannot be left blank';     
                else
                if (abc.value == '')
                        document.getElementById('nodata').innerHTML = 'Job name cannot be left blank';
             else
                if (bcd.value == '')
                       document.getElementById('nodata').innerHTML = 'Email cannot be left blank';
             else
             if (cde.value == '')
                        document.getElementById('nodata').innerHTML = 'Password cannot be left blank';
                    return false;
         function checkspace()
            abc = document.getElementById('jobn');
           var filter=(/\s/g);
          if (!filter.test(abc.value))
              return false;
         else
          document.getElementById('checkspace').innerHTML = 'Please do not enter spaces in job name field';
           return true;
    </script>
    </head>
    <body bgcolor="#555555">
    <form name="myForm" action="/WorkProject/WebContent/index.jsp" method="post" onSubmit="return returnall();" >Though the pages runs fine..when i compile i get this error " Void function cannot return a value"in form tag above.. How can i solve this error? please help..

    Thanks a lot..I solved that problem..
    <script type="text/javascript">
    try{
         var variable3=(document.forms[0]).server_Name.value;
         var variable=(document.forms[0]).job_Name.value;
         }catch(err){}
      function  getAll()
           checkempty();       
           checkspace();
           checkemail(variable3);                        
       function checkemail(variable3)
          bcd = document.getElementById('EmailAd');
          var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
          if (!filter.test(bcd.value)&& bcd.value != '')
          document.getElementById('emailvalid').innerHTML = 'Please enter a valid email Address';
        function checkempty()
              var abc, bcd, cde, def, efg, fgh, ghi
              abc = document.getElementById('jobn');
              bcd = document.getElementById('EmailAd');
              cde = document.getElementById('pass');
              if (abc.value == ''&& bcd.value == ''&& cde.value == '')
                   document.getElementById('nodata').innerHTML = 'Please enter jobname,Email and Password ';
             else
             if(bcd.value == ''&& cde.value == '')
                       document.getElementById('nodata').innerHTML = 'Email and Password cannot be left blank';
             else
             if(abc.value == '' && cde.value == '')
                       document.getElementById('nodata').innerHTML = 'Job name and Password cannot be left blank';
                else
                if(abc.value == ''&& bcd.value == '')
                     document.getElementById('nodata').innerHTML = 'Job name and Email cannot be left blank';     
                else
                if (abc.value == '')
                        document.getElementById('nodata').innerHTML = 'Job name cannot be left blank';
             else
                if (bcd.value == '')
                       document.getElementById('nodata').innerHTML = 'Email cannot be left blank';
             else
             if (cde.value == '')
                        document.getElementById('nodata').innerHTML = 'Password cannot be left blank';
         function checkspace()
            abc = document.getElementById('jobn');
           var filter=(/\s/g);
          if (!filter.test(abc.value))
         else
          document.getElementById('checkspace').innerHTML = 'Please do not enter spaces in job name field';
    </script>I made the following changes in the code to call getAll method..
    <td><input type="button" value="Submit" name="Submit" action="/WorkProject/WebContent/index.jsp" method="post" onClick=" getAll();" >

  • Name attribute not giving the desired result in form tag

    Hi,
    I am using struts and the name attribute in form tag is not giving me the desired reuslt. The code is
    <html:form name="loginActionForm" type="source.form.LoginActionForm" action="/login.do" method="post">
    </html:form>
    when I am trying to use the name in javascript then I am getting an error
    "document.loginActionForm " is null or not an object.Where am I going wrong?

    I did so but the name I have used in the form tag is the same as what i have used in javascript.I dont think that it is a javascript error and it must be some mistake I made in the form tag.Also one more thing is it necessary to use the type attribute if you use the name attribute.

Maybe you are looking for