Struts reusable forms

First, I am new to struts.
          I would like to use a form with different actions. However, depending on the
          action the required field(s) would be different. Is there an idiom( or
          pattern) used for this type of problem.
          I though about letting the action valdidate that the required field was
          present. Also, what about having different forms that extend a base form and
          then provide their own specialized validate()?
          dlm
          

hi mate,
i am using these properties with 16 different names in my jsp.
how come these values are stored in the foem bean?
can you please guide me with some sample code?
regards and thanks in advance

Similar Messages

  • How to use form name in struts html:form tag

    Hi,
    I want to validate text box value, if it is ordinary html form I would have done like this <form name="myform" action="xxxx.jsp" onsubmit="return validate()">
    But am using struts html:form tags. In this case how can I use/specify name for a form.
    Can any one help me.
    Thanks

    The name of the form comes from the actionForm you have defined backing it.
    View source on the generated page to see what HTML it constructs.
    You are able to use the onsubmit event with the <html:form> tag just like the standard one, so if all you want to do is that:
    <html:form action="/saveUser" onsubmit="return validate()">
    ...You can also give it a styleId, which will generate an id in the HTML.
    See the tag documentation for details: http://struts.apache.org/1.2.x/userGuide/struts-html.html#form

  • JDev10g and ADF/Struts input form errors

    I followed a demo for creating an input JSP form from Business Components. However, although I can create and run a report or read-only form without a problem, I cannot create and run an input form at all as I keep getting the following error:
    javax.servlet.jsp.JspException: No getter method for property FirstName of bean org.apache.struts.taglib.html.BEAN
         at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)
    Any ideas?

    Justin,
    This usually happen because the data binding called FirstName cannot be found in the binding container associated your JSP.
    The binding container associated with your page is most likely the name of your page with UIModel.xml.
    You can see the list of bindings available in the binding container by selecting the DataBinding.cpx file in the Navigator and look at the Struture Pane.
    The FirstName binding might not be thre of the wrong binding container may be associated with the page.

  • Struts html:form vs form

    Hi,
    I'm trying to get form validation working in struts but am running into a bit of difficulty. I have a couple of questions:
    1) When an ActionError is returned - does the input form have to have used <html:form> tags for the errors to be shown. The reason i ask is because at the moment i am using the original <form> tags and when the request is returned to the input page there is just a blank page - i though this might be because i am not using the specialised struts html tags? This leads nicely on to my 2nd question... :o)
    2)Now the reason i am not using these tags is because when i try and create a form using these tags the text input areas/buttons etc do not appear - here is my code:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
      <head>
        <title>iQ Holiday Entitlement Calculator</title>
      </head>
      <body>
        <p><html:errors property="date"/></p>
        <html:form action="/iq/hr/holiday/calculate" name="calculatorForm" type="iq.hr.holiday.calculator.forms.CalculatorForm" >
          <table width="45%" border="0">
            <tr>
              <td>Day: <html:text property="day" /></td>
            </tr>
            <tr>
              <td>Month: <html:text property="month" /></td>
            </tr>
            <tr>
              <td>Year: <html:text property="year" /></td>
            </tr>
            <tr>
              <td colspan="2" align="center"><html:submit styleClass="button" value="Go"/></td>
            </tr>
          <table>
        </html:form>
      </body>
    </html:html>The text literals "Day:", "Month:", "Year:" appear but no text field with which to enter the text!
    I would very much appreciate any help anyone can offer!
    Many thanks

    <%@ page contentType="text/html; charset=iso-8859-1"
    language="java" import="java.sql.*" errorPage="" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld"
    prefix="html" %>
    <html:html>
    <head>
    <title>iQ Holiday Entitlement Calculator</title>
    </head>
    <body>
    <p><html:errors property="date"/></p>
    <html:form action="/iq/hr/holiday/calculate"
    te" name="calculatorForm"
    type="iq.hr.holiday.calculator.forms.CalculatorForm"
    >
    <table width="45%" border="0">
    <tr>
    <td>Day: <html:text property="day" /></td>...
    </tr>
    <table>
    </html:form>
    </body>
    </html:html>try:
    1.check your Action to see if the forward is ok (I think that your forward=... is not reachable if you have some errors)
    2.delete property="date" from <html:errors.../>
    3.close <table>tag
    4.delete <html:html> and </html:html> from your code
    5.maybe you have some errors in your and you have errorPage=""

  • Struts: passing form

    In struts we assign the formBean to form in the action class as following;
    FormBean formBean = (FormBean)form;is it possible to pass formBean as a parameter to another class? if yes, how can that be done?

    Nawnit_Kishore wrote:
    JSP 2 under <html:form> tag:
    <input type="hidden" value="<%=(String) request.getAttribute("batchNo")%>" id="batchNo" name="batchNo"/>change the type of batchNo from hidden to text and check whether you are getting the value in JSP2 or not. If you are getting then you should be able to get the value using ActionForm(or DynaForm) object in JSP2 action.

  • Error in Struts Application, Form Submit

    I've developed a simple struts application which allows user to key in inputs thru a form(registration.jsp), submit n display e inputs keyed in in another page(details.jsp).
    i'd succesfully integrate e pdk-struts application to portal, but wen i click on 'Submit', my action r not performed, not directed to my details.jsp, neither do it shows any error.
    However, one thing i realised is tat wen integrated to portal, e codes for my action r changed:
    registration.jsp
    <html:form action="/register" focus="name">
    after integrated wit Portal, it was translated to:
    <form name="registerForm" method="post" action="http://smeagel:7778/portal/page">
    <INPUT TYPE="hidden" name="_pageid" value="6,3,6_22" />
    <INPUT TYPE="hidden" name="_dad" value="portal" />
    <INPUT TYPE="hidden" name="_schema" value="PORTAL" />
    <INPUT TYPE="hidden" name="_piref6_108279_6_3_22.strutsAction" value="register.do" />
    After Submit button was clicked, i was directed to a new URL, http://smeagel:7778/portal/page
    Any solutions??

    provider.xml
    <?xml version = '1.0' encoding = 'UTF-8' standalone='yes'?>
    <?providerDefinition version="3.1"?>
    <provider class="oracle.portal.provider.v2.DefaultProviderDefinition">
    <session>true</session>
    <passAllUrlParams>true</passAllUrlParams>
    <portlet class="oracle.portal.provider.v2.DefaultPortletDefinition">
    <id>1</id>
    <name>MyPortlet</name>
    <title>- Registration Form -</title>
    <description>My Portlet Description</description>
    <timeout>40</timeout>
    <showEditToPublic>false</showEditToPublic>
    <hasAbout>false</hasAbout>
    <showEdit>false</showEdit>
    <hasHelp>false</hasHelp>
    <showEditDefault>false</showEditDefault>
    <showDetails>false</showDetails>
    <inputParameter class="oracle.portal.provider.v2.DefaultParameterDefinition">
    <name>MyParam</name>
    <displayName>My Portlet Parameter</displayName>
    </inputParameter>
    <renderer class="oracle.portal.provider.v2.render.RenderManager">
    <renderContainer>true</renderContainer>
    <renderCustomize>true</renderCustomize>
    <autoRedirect>true</autoRedirect>
    <contentType>text/html</contentType>
    <showPage>/registration.jsp</showPage>
    <showPage class="oracle.portal.provider.v2.render.http.StrutsRenderer">/register.do</showPage>
    </renderer>
    </portlet>
    </provider>
    I'd saw some example, which using <defaultAction>, however, wen i put in <defaultAction>/register.do</defaultAction>
    i'll have error in my Provider Test Page. Validation Unsuccessful.
    Error: Class oracle.portal.provider.v2.render.http.StrutsRenderer has no set or add method for tag "defaultAction"
    Is <defaultAction> a necessary tag? Is tat e reason y my application isnt running?

  • Struts and formS

    Hello,
    I need to manage 2 forms in the same JSP page using struts framework. This page is launched by an action building the first form data.
    The first form works ok.
    But how can I build the second form?
    Thanks,
    Arno

    Thanks!
    The problem was to call the second action, I tried with an <jsp:include "/myAction.do"... and it works. The first action was called by a <html:link....
    I don't know if there are others solutions to call an action from a page (except a link) ?
    Arno

  • Uix:dateField inside struts html:form

    this renders calendar:
    <uix:form name="f8">
    <uix:dateField name="e2" />
    </uix:form>
    this not:
    <html:form styleId="f3" action="showsth.do">
    <uix:dateField name="e2" />
    </html:form>
    where html:form is struts form
    why?
    what am I doing wrong?
    I thing use uix and struts together would be amazing but ...

    Unfortunately, we do not support uix elements inside struts form element.

  • Struts html:form how to use autocomplete  = "off"

    Hi... I am having a problem when I try to use Autocomplete = "OFF" on my jsp page using struts...
    my question is how to use autocmplete on html:form / text tag? to disable autocomplete!

    The "value" for the checkbox comes from nested content inside the <html:multibox> tag - in this case you are using "item"
    "items" is the complete list of items
    "selectedItems" should be a String[] of all the selected values.
    Each time it adds a checkbox, it compares "item" with its array of "selectedItems".
    If "item" is in there, then the box is populated as "selected" otherwise not.
    Does that explain it?
    Cheers,
    evnafets

  • How struts invoking form getters and setters of a property

    hi,
    can anyone explain me how struts framework was calling the form properties getters and setters
    i have an idea like preparing a string such that
    if propert of text box is propertName, preparring a string with get and set making first letter capital
    setPropertyName
    getPropertyName
    and invoking that method in form property
    but i dont think this is the exact way struts follow , there could be a prcise and direct way to invoke propert methods
    i have another idea
    getting the declared method of the form class and search for the string propertyname in the methods name, and sure this is also not perfect way
    with regards
    satya

    can anyone tell where i can find libraries for access/manipulate beans.
    and sample example to invoke getters and setter of the property but not like preparing String "setPropertyName" or "getPropertyName" and invoking the method i beleive there should be standard way
    and also setPropertyName may take different type parameters i cannot keep number of if conditions to check for different datatypes
    with regards
    satya

  • Related to struts validation form

    Hi all,
    When entering validations on a form in validation.xml, If you have a
    fieldA with "depends=required,maxlength" and FieldB with "depends=required,email".
    If when i give fieldA with 40characters but its permitted length is 20 and FieldB is empty. Now when i click submit button it shows the error only for fieldB.
    When i give a correct email id in fieldB then FieldA error for max length is triggered..
    Is there a way for both to appear at the same time when the
    Submit button is first clicked?

    You may have more luck if you ask this in a forum devoted to Struts. There's one at their own homepage over there at apache.org.

  • Struts Validator Form

    Hi,
    I have an application J2EE Struts that receives data via a http call and url parameters from another system.
    Example url calling my system is:
    http://<server ip>:<server port>/application/actionName.do?custName=LADY%20TESTINA%20TEST&custNo=01512865900&custAdd=45%20Test%20Street%20Testville%20%20%20%20%20%20&notes=this%20is%20a%20'test'%20ok%20try%20& quot;this& quot;%20as%20well
    I've having problems when the url contains encoded charachters such as & quot; at the point the form bean is created for the above I've printed out the bean contents for the "notes" value and I'm getting: this is a 'test' ok try
    Which means that anything after the & quot; isn't being added to the bean value, I guess this is because of the & characheter when the url is parsed it's splitting the values thinking that there's another parameter?
    Note the & quot; above shouldn't have a space in it.
    What is the best way to handle this?
    Thanks.
    Edited by: user618008 on 22-Feb-2011 03:59
    Edited by: user618008 on 22-Feb-2011 04:00

    public void parseSwfURL(String testURL) {
                   String subURL = null;
                   if(testURL!=null){
                        String[] splitedURL = testURL.split("\\?");
                        if(splitedURL.length >=2){
                        parameterBean.setObjectName(splitedURL[0]);
                        subURL = splitedURL[1];
                   populateParameterBean(subURL, parameterBean);
    private void populateParameterBean(String subURL1) {
              if(subURL1!=null) {
                   String[] subURL = subURL1.split("\\&");
                   String item = null;
                   String[] itemPair = null;
                   String itemValue = null;
                   for (int i = 0; i < subURL.length; i++) {
                        item = subURL;
                        itemPair = item.split("\\=");
                        if(itemPair.length == 2){
                             itemValue = itemPair[1];
                        else{
                             itemValue = "";
                        String type = itemPair[0];
                        if(type.equalsIgnoreCase("<<your parameters>>")){
    //set your action bean here

  • Reusable form validation

    Hi all,
    Whenever I work with form validation, I prefer to use manual
    ColdFusion validation rather than the automated cfform or
    Javascript validation.
    I have included a sample of one of my form validation scripts
    below, and was wondering if there was a way of scripting this whole
    thing, perhaps to loop through the form collection to perform the
    same sort of validation on the fields included in the collection.
    Is there some sort of attribute I can add to the fields that
    require validation to flag them to the loop?
    Thinking about it I would need something to flag minimum and
    maximum length, regular expressions, and replace() of fields on
    some occasions. Am I overcomplicating something for the sake of
    saving some coding time?
    Thanks in advance,
    Paul
    Attached code:

    What you could do is look for things you do frequently and
    write a custom tag/udf/cfc to make the code re-useable. For
    example, many of my forms just have two text boxes looking for
    dates. I have a custom tag that makes sure both values actually are
    dates, that they are in the correct order, that they are not too
    far apart, and that they are within a specified period.

  • How to map GUI Bean with struts action form?

    Hi,
    I am new to struts and I have to integrate a GUI Based Bean to struts actionform. I am desperately looking for some tips. I would be much gratefull.
    See ya :)

    Hello.
    public vlass MyForm extends ActionForm {
    private MyBean myBean;
    public MyBean getMyBean() {
    return myBean;
    public void setMyBean(MyBean myBean) {
    this.myBean = myBean;
    }

  • Assigning java script array to a variable in struts form class

    Hi,
    I am trying to send a javascript array of string from jsp to struts action form.
    I have constructed a javascript array and assigned it to the form variable. But iam not able to access the variable in Action form. :( please let me know as to how i can send a string array in javascript to action form?.
    JavaScript
    var scriptarray = new Array();
    // code for populating the array
    document.MyForm.javaArray = scriptArray;
    document.MyForm.action="MyAction.do?dispatch=handlerMethod";
    document.MyForm.submit();

    var input = document.createElement("input");
    input.setAttribute("type", "hidden");
    input.setAttribute("name", "bla..bla");
    input.setAttribute("value", "bla..bla");And in addition to that.. Google is still alive

Maybe you are looking for

  • Upgrading from Solaris 8 to Solaris 10

    Hi I am in the process of upgrading from Solaris 8 to 10 on a sparc server. What I would like to know if anyone has experienced compatibility issues during the upgrade with the Korn and C Shell as well as perl.

  • How to set cashe '0' in fixed assets

    Hi guys well i am facing a problem in fixed assest numbers,when we insert a data manualy from application then we have 20 numbers forwarded number. for example we have sequence in asset number (1 2 3 4 22 23 24 25 26 36 37 38 39 and so on i want to s

  • How to Install the Downloaded NetBeans(*.nbm) Modules for Sun Java Studio

    Dear All, I have downloaded NetBeans Modules files with Extension *.nbm, and they are not getting installed, when I double click on them, or if I go through the Update Center and Select the Downloaded Modules even then also they are not getting insta

  • What are skewX and skewY in Motion XML?

    In the motion XML, what is skewX and skewY? The spec says "shearing along X" and "shearing along Y". However, according to my research, equal shearing along X and Y does not result in rotation(although that's what the spec says about skewX and skew Y

  • URLConnection.getInputStream() craches thread

    Hi I'm trying to parallelize a downloading process i'm developing, and my download started to behave a bit sporadic. The thread dies right after the System.out.println("1") in the following code snippet, s is an url. for(String s:urls) {   try {