About struts

i am using struts. i hav a problem with struts.
i have a form .in that form it contains two buttons .
one is"+" and another one is "-".
if i press + it will add two text fields to my from .
if i again pree + it will add another two text fields(total 4).
if i press - it will delete that text fields.
that code is written in javascript.ie working fine also.
what is my problem is .how to write a bean for that .
i dont know how many text fields are there in my form .
aome time 2 ,aome times 4,some times 10.i dont know exactly .
how to write a bean in this situation.
plz help me
thax alt

Do not add the text fields using java script.
I guess you are using a collection object in your backing bean to hold your text boxes.
1. When ever you press '+' submit the form. In your action class, add two records to the collection object that holds your text boxes. Now when you submit your form, the newly added records are also submitted.
2. Now when you press '-', again submit the form and clear the records added previously.
Regards,
SirG

Similar Messages

  • Wls 8.1 sp2: weblogic.jspc complains about struts-html tags

              Hi,
              I am trying to compile jsps with weblogic.jspc, which use struts' html tags. However,
              the compilation fails with the following message:
              [java] Translation of /views/viewPageBody.jsp failed: (line 3): Error in using
              tag library uri='/tags/struts-html' prefix='html': The Tag class 'org.apache.struts.taglib.html.BaseTag'
              has no setter method corresponding to TLD declared attribute 'server', (JSP 1.1
              spec, 5.4.1)
              I opened the BaseTag class from the struts jar and found the setter exists for
              the attribute 'server' of html tld. So does the property 'server'. The property
              'server' is a string and the parameter in the setter is a string. I read about
              the jspc errors in wls 8.1 about the setter parameter being of different type
              than the property. However, that is not the case here. I tried using both Sun's
              and BEA's jdk. None of them help. Btw, there is another attribute mentioned in
              the html tld, which is 'target'. The compiler doesn't complain yet about this.:(
              Also, I happened to compile other apps which have struts logic tags.
              My environment:
              OS: Win2k sp3
              WLS: 8.1 sp2
              JDK: Sun's 1.4.2 sp4 / Bea's 1.4.1 sp5 (tried both)
              Ant: 1.5.3 (I had an issue earlier with ant until I found that Bea officially
              without any mention supports only ant 1.5.3.)
              I would appreciate any help in this regard.
              Thanks,
              Abbas
              

              What version of Struts are you trying to use?
              Are you certain you're not encountering a different instance of that class in
              an unexpected location in your classpath?
              "Abbas" <[email protected]> wrote:
              >
              >Hi,
              >I am trying to compile jsps with weblogic.jspc, which use struts' html
              >tags. However,
              >the compilation fails with the following message:
              >
              >[java] Translation of /views/viewPageBody.jsp failed: (line 3): Error
              >in using
              >tag library uri='/tags/struts-html' prefix='html': The Tag class 'org.apache.struts.taglib.html.BaseTag'
              >has no setter method corresponding to TLD declared attribute 'server',
              >(JSP 1.1
              >spec, 5.4.1)
              >
              >I opened the BaseTag class from the struts jar and found the setter exists
              >for
              >the attribute 'server' of html tld. So does the property 'server'. The
              >property
              >'server' is a string and the parameter in the setter is a string. I read
              >about
              >the jspc errors in wls 8.1 about the setter parameter being of different
              >type
              >than the property. However, that is not the case here. I tried using
              >both Sun's
              >and BEA's jdk. None of them help. Btw, there is another attribute mentioned
              >in
              >the html tld, which is 'target'. The compiler doesn't complain yet about
              >this.:(
              >Also, I happened to compile other apps which have struts logic tags.
              >
              >
              >My environment:
              >OS: Win2k sp3
              >WLS: 8.1 sp2
              >JDK: Sun's 1.4.2 sp4 / Bea's 1.4.1 sp5 (tried both)
              >Ant: 1.5.3 (I had an issue earlier with ant until I found that Bea officially
              >without any mention supports only ant 1.5.3.)
              >
              >I would appreciate any help in this regard.
              >
              >Thanks,
              >
              >Abbas
              

  • Where to learn about Struts?

    Hi, I wanna learn Java on the server-side, and the first thing I'd like to learn is Struts, cause I constanly hear about it, so I've searched for a tutorial about it but couldn't find, could someone please advise me some tutorial or a good place to start with Struts?

    The documentation at struts.apache.org is a starting point.
    You can find the free ebook at
    http://www.ihelpers.co.kr/programming/reference/JakartaStrutsLive.pdf
    Thanks

  • I want to Know More About Struts Framework

    Hai i am kiran patil from tybca m.s.uni baroda
    we have elective of struts framework i want to know in deep and as i am begineer i want to know more about it
    thank you if u can help me
    Regards,
    kiran

    http://struts.apache.org/

  • Question about struts-config.xml

    Hi,
    In the struts-config.xml,
    What is the difference about "redirect="true" and redirect="false" ?
    thanks,
    happybaobao

    Hello,
    redirect = truemeans that the ActionForward () statement in your execute method of the Action class will perform a response.sendRedirect. You can see that the URL is getting altered in the clients browser
    redirect = false means the vice-versa.
    I would recommend that you go through the Struts official site and see the DTD specifications in the URL
    http://struts.apache.org/dtds/struts-config_1_2.dtd
    for more details.
    Thanks and regards,
    Pazhanikanthan. P

  • Please help me to get knowledge about struts tags(html,bean,logic).

    hai Friends,
    I know basics of struts. I have done basic examples.
    I have to know , how to get dynamic values in "view".
    Instead of writing like this..
    <html:select property="color1" size="4" >
    <html:option value="red">red</html:option>
    <html:option value="blue">blue</html:option>
    <html:option value="green">green</html:option>
    <html:option value="orange">orange</html:option>
    <html:option value="red">red</html:option>
    <html:option value="pink">pink</html:option>
    </html:select>
    How to use <html:options> tag to get dynamic values.
    I have to get knowledge about this tags, so please suggest some
    sites (or) send some materials (or) send some live examples("[email protected]"). It will very useful..
    thanks friends....
    take care...
    bye.....
    will be very useful for me...

    you have to have a list of label and value pairs in you ActionForm then define it in your jsp to able able to use it in your <html:options> tag
    ActionForm
    public final class ColorForm extends ActionForm {
        public String color;
        public void setColor(String color) {
            this.color = color;
        public String getColor() {
            return this.color;
        public List getColorList() {
            List l = new ArrayList();
            ColorLabelValueBean lvRed = new ColorLabelValueBean();
            lv.setLabel("Red");
            lv.setValue("R");
            l.add(lv);
            ColorLabelValueBean lvGreen = new ColorLabelValueBean();
            lv.setLabel("Green");
            lv.setValue("G");
            l.add(lv);
            ColorLabelValueBean lvBlue = new ColorLabelValueBean();
            lv.setLabel("Blue");
            lv.setValue("B");
            l.add(lv);
            return l;
    }Label - Value Bean
    public final class ColorLabelValueBean implements Serializable {
        private String label;
        private String value;
        public void setLabel(String label) {
            this.label = label;
        public String getLabel() {
            return this.label;
        public void setValue(String value) {
            this.value = value;
        public String getValue() {
            return this.value;
    }JSP
    <bean:define id="colorListOption" name="ColorForm" property="colorList" type="java.util.List" />
    <html:select property="color">
         <html:option value=""></html:option>
         <html:options collection="colorListOption" labelProperty="label" property="value" />
    </html:select>
    ...Good luck!

  • Question about struts inside javascript variable

    Hi, actually i'm using a struts + javascript to create HTML code that i use inside a popup window...
    My (working) code is:
              idoc="";
              /* var cols = parent.document.getElementById('rowA').getElementsByTagName('THEAD')[0].getElementsByTagName('TH'); */
              var idoc='<html:form styleId="InsertNewItem" action="/nw/insertnewitem.do?target='+parent.newPop.action+'">';
              idoc+='<TABLE><TBODY>';
              var hiddenForm = getParentObj('hidden_data_form');
              var cols = hiddenForm.getElementsByTagName('INPUT');
              var test;
              test="cippa";
              for(k = 0; k < cols.length; k++) {     
                   if(cols[k].id.substring(0,3) == "hh_")
                        idoc += "<TR><TD>";
                        idoc += cols[k].id.substring(3);
                        idoc += "</TD><TD>";
                        idoc += '<html:text property="'+cols[k].id+'" value=""/>';
                        idoc += "</TD></TR>";
              idoc+='</TBODY></TABLE>';
              idoc+='</html:form>';
              var towr = document.getElementById("subwin_body");
              towr.innerHTML = idoc;
    The problem is when i try to add a <html:select> to the code, more precisely i added just before the end of the table these lines:
              idoc += "<TR><TD>Ditta:";
              idoc += "</TD><TD>";
              idoc += '<html:select property="ditta_id">';
              idoc += '<html:options collection="sel_ditta_list" labelProperty="label" property="value"/>';
              idoc += '</html:select>';
              idoc += "</TD></TR>";          
    ... but i cannot get it to work because struts seems to make some mistake with quotes and in javascript console window i get this error:
    Error: unterminated string literal
    File source: http://localhost:8180/nw/jsp/insertNewItemOperatore.jsp
    Row: 121, Column: 10
    Source Code:
    idoc += '<option value="1">1</option>
    (note the missing ending single-quote)
    I can't understand why because with <html:text> field the same "trick" works fine... any ideas?
    Thanks in advance
    Luca
    Message was edited by:
    spallared

    can you post all of your source code for the .jsp and then try running the page and once it fails do a View Source and then paste in all the generated code so that we can look at that as well.
    i'm not totally positive but i have a pretty good feeling what is going wrong. the struts optionsCollection tag will render a bunch of <option> elements but print a newline after each one, which means you probably end up with something like
    var whatever = '<option ...>.........<option>
    <option ...>.........<option>
    <option ...>.........<option>
    <option ...>.........<option>';
    correct? if so, that is not valid javascript.
    Message was edited by:
    den2681

  • To Shay Shmeltzer about struts in JDeveloper10.1.3.3

    hi shay
    As per u said i moved to 10.1.3.3 can u please give solution to this.
    Previously i was run my struts app in JDeveloper 10.1.2, it was successful run.
    I am trying to run the same application using Jdeveloper 10.1.3.3,but it is not running.
    i am selecting the template as (JSP,Struts ADF BC)web application
    the structure is like below
    +model
    - viewcontroller
    -application sources
    - view
    L AdminAction.java
    L ApplicationResources.properties
    -webcontent
    -WEB-INF
    L struts-config.xml
    L web.xml
    -WEB-INF/lib
    struts.jar
    L admin.jsp
    L succ.jsp
    L fail.jsp
    In this app, i observed when it is run on Enbedded OC4J Server it displays the first page as admin.jsp the url is
    http://hostname/context /admin.jsp
    when i perform any action on this page it is not going to page what i map (i,e succ.jsp , showing page not found ) the url is
    http://hostname/admin.do here it is not taking the context
    Do i need to do any new setting other then Jdeveloper 10.1.2 ,why becoz it is ruuning in that.
    can anybody have the solution for JDeveloper10.1.3.3 (struts)
    thanks

    hi shay
    I got the answer why it was not getting ie,
    -application sources
    - view
    L AdminAction.java
    L ApplicationResources.properties
    In struts-config.xml
    <action path=/admin type=view.AdminAction ...../>
    Here it is not taking the package name (view).If i create the above two files without package it is working.But it is not the correct thing when i want to create files(java,properties, ..) in different packages how can i do?
    can u tell me the solution if i want to create it using package like previous program?

  • Question about Struts and ActionForm

    Hi,
    I've a LoginForm class that extends ActionForm and the login.jsp page accepts 2 fields - "username" and "password" and there are corresponding setters and getters in LoginForm.java. As part of moving this to container managed security (using login modules), I want to change the field names to j_username and j_security. I made the change to the login.jsp page and also to the getters and setters (made them getJ_username, getJ_password) but I keep getting the "getter is not defined" struts related error. any thoughts?

    You would need to follow naming convention. It should be
    userName,
    I never tried with underscore, try j_userName (caps N). I don't think it will work.

  • Question about Struts and ActionForward

    Hi all.
    I'm having a problem regarding the use of DataAction and DataPage
    Imagine this scenario:
    1 - I have a simple web application. Its context root is http://host:port/. This web application has one jsp page called page1.jsp.
    2 - On struts configuration, I drop a DataAction called action1 and a DataPage called page1, wich holds page1.jsp, into the diagram, and link the DataAction to the DataPage using a Forward.
    3 - I start the application by clicking on the DataAction action1.
    4 - The application shows page1.jsp in the browser, because of the forward component that links de DataAction to the DataPage, but on the address bar of the browser the url is: http://host:port/action1.do. Here is the problem. I expected that I should see http://host:port/page1.do.
    5 - Because of this problem, if I refresh the page using the browser, the DataAction is executed again, but it can't. I thought the forward mechanism between a DataAction and a DataPage would cause some kind of url redirection to the browser.
    I'm using Internet Explorer to do these tests.
    Do you guys know how can I solve this problem?

    Hi fred... thanks for your post....
    Well, I'm in trouble then......
    I know that JHeadStart has the capability to detect if user have used the back or forward buttons from the browser......... If I could detect when the refresh command is used, it would solve the problem.
    I'm used to create DataAction to call some common methods from the ApplicationModule, so I can centralize code by providing different forwards to many DataPages.
    Does anyone have a best practice on how to use DataActions in conjunction with DataPages?
    Regards.

  • Question about struts

    HI
    i just ask,
    if i want to connect struts using Mysql. apart from web.xml and struts-config.xml
    any other xml file i have to configure.
    pls any one can guide me.

    This is not the right forum to ask this question.
    Anyway if you use tomcat then you can provide the connection settings in the context.xml file under the META-INF directory of your application.
    For more information refer to
    http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
    (Presuming you are using tomcat for deployment of your web-app)

  • It's about struts

    can you help me in this code
    <html:select name="form" property="list" onchange="?????????">
    <logic:itreate id="name" name="form" property="list">
    <html:option><bean:write ................../></html:option>
    </logic:itreate>
    </html:select>
    i want to pass the valuein the select option to the action class on change

    onchange="document.forms[0].submit()"
    will submit the form, with the new value selected in the dropdown box.
    This will then go through the standard struts form/action processing.

  • Basic question about Struts

    Hello,
    I am going through the struts sample application (struts-example.war) and I am trying to understand the firtst global forward. Here it is:
        <forward   name="logoff"               path="/logoff.do"/>How does the application knows that "logoff.do" is mapped to the logon.jsp page?
    Can anyone answer this question please?
    Thanks in advance,
    Julien.

    Thanks for your reply ADCWorks,
    What I don't understand is that I have disabled the local forward for the logoff action (the struts-config.xml is included here). How does Struts know that the logoff.do is mapped to logon.jsp? I doubt it is hard-coded in the servlet...
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <!--
         This is the Struts configuration file for the example application,
         using the proposed new syntax.
    -->
    <struts-config>
    <!-- ========== Data Source Configuration =============================== -->
    <!--
    <data-sources>
       <data-source>
         <set-property property="autoCommit"
                          value="false"/>
         <set-property property="description"
                          value="Example Data Source Configuration"/>
         <set-property property="driverClass"
                          value="org.postgresql.Driver"/>
         <set-property property="maxCount"
                          value="4"/>
         <set-property property="minCount"
                          value="2"/>
         <set-property property="password"
                          value="mypassword"/>
         <set-property property="url"
                          value="jdbc:postgresql://localhost/mydatabase"/>
         <set-property property="user"
                          value="myusername"/>
       </data-source>
    </data-sources>
    -->
      <!-- ========== Form Bean Definitions =================================== -->
      <form-beans>
        <!-- Logon form bean -->
        <form-bean       name="logonForm"
                         type="org.apache.struts.validator.DynaValidatorForm">
          <form-property name="username" type="java.lang.String"/>
          <form-property name="password" type="java.lang.String"/>
        </form-bean>
        <!-- Registration form bean -->
        <form-bean      name="registrationForm"
                        type="org.apache.struts.webapp.example.RegistrationForm"/>
        <!-- Subscription form bean -->
        <form-bean      name="subscriptionForm"
                        type="org.apache.struts.webapp.example.SubscriptionForm"/>
      </form-beans>
      <!-- ========== Global Forward Definitions ============================== -->
      <global-forwards>
        <forward   name="logoff"               path="/logoff.do"/>
        <forward   name="logon"                path="/logon.jsp"/>
        <forward   name="registration"         path="/registration.jsp"/>
        <forward   name="success"              path="/mainMenu.jsp"/>
      </global-forwards>
      <!-- ========== Action Mapping Definitions ============================== -->
      <action-mappings>
        <!-- Edit user registration -->
        <action    path="/editRegistration"
                   type="org.apache.struts.webapp.example.EditRegistrationAction"
              attribute="registrationForm"
                  scope="request"
               validate="false">
          <forward name="success"              path="/registration.jsp"/>
        </action>
        <!-- Edit mail subscription -->
        <action    path="/editSubscription"
                   type="org.apache.struts.webapp.example.EditSubscriptionAction"
              attribute="subscriptionForm"
                  scope="request"
               validate="false">
          <forward name="failure"              path="/mainMenu.jsp"/>
          <forward name="success"              path="/subscription.jsp"/>
        </action>
        <!-- Process a user logoff -->
        <action    path="/logoff"
                   type="org.apache.struts.webapp.example.LogoffAction">
          <!--forward name="success"              path="/index.jsp"/-->
        </action>
        <!-- Process a user logon -->
        <action    path="/logon"
                   type="org.apache.struts.webapp.example.LogonAction"
                   name="logonForm"
                  scope="session"
                  input="logon">
          <exception
                    key="expired.password"
                   type="org.apache.struts.webapp.example.ExpiredPasswordException"
                   path="/changePassword.jsp"/>
        </action>
        <!-- Save user registration -->
        <action    path="/saveRegistration"
                   type="org.apache.struts.webapp.example.SaveRegistrationAction"
                   name="registrationForm"
                  scope="request"
                  input="registration"/>
        <!-- Save mail subscription -->
        <action    path="/saveSubscription"
                   type="org.apache.struts.webapp.example.SaveSubscriptionAction"
                   name="subscriptionForm"
                  scope="request"
                  input="subscription">
          <forward name="subscription"    path="/subscription.jsp"/>
          <forward name="success"         path="/editRegistration.do?action=Edit"/>
        </action>
        <!-- Display the "walking tour" documentation -->
        <action    path="/tour"
                forward="/tour.htm">
        </action>
      </action-mappings>
      <!-- ========== Controller Configuration ================================ -->
      <controller>
        <!-- The "input" parameter on "action" elements is the name of a
             local or global "forward" rather than a module-relative path -->
        <set-property property="inputForward" value="true"/>
      </controller>
      <!-- ========== Message Resources Definitions =========================== -->
      <message-resources
        parameter="org.apache.struts.webapp.example.ApplicationResources"/>
      <message-resources
        parameter="org.apache.struts.webapp.example.AlternateApplicationResources"
        key="alternate">
      </message-resources>
      <!-- ========== Plug Ins Configuration ================================== -->
      <plug-in className="org.apache.struts.plugins.ModuleConfigVerifier"/>
      <plug-in className="org.apache.struts.webapp.example.memory.MemoryDatabasePlugIn">
        <set-property property="pathname" value="/WEB-INF/database.xml"/>
      </plug-in>
      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
                         value="/WEB-INF/validator-rules.xml,
                                /WEB-INF/validation.xml"/>
      </plug-in>
    </struts-config>

  • Using chinese characters in struts-config.xml

    Hi
    i am developing an application in Chinese language where i need to create all the urls in the Chinese language. i am using struts 1.3.5.can anyone tell me is it possible to use Chinese characters in struts-config.xml action mappings? i tried but it is not working. is there ant way really?
    Regards,
    A.

    Don't know about struts specifically, but for Chinese URLs to work you would need to convert to punycode at some point, to comply with IDNA: http://en.wikipedia.org/wiki/Punycode
    Are you doing that?

  • How to instantiate object in JSP/STRUTS page?

    I worked through the STRUTS tutorial (http://rzserv2.fhnon.de/~lg002556/struts/Doku.html) but I get errors when I try to instantiate an object of a class that is in my WEB-INF/classes directory:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 14 in the jsp file: /BookSerialize.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    D:\Programme\jakarta-tomcat-4.1.12\work\Standalone\localhost\strutsdemo\BookSerialize_jsp.java:86: cannot resolve symbol
    symbol : class Book
    location: class org.apache.jsp.BookSerialize_jsp
    Book book = new Book();
    ^
    The Book.class (and other classes) is in the WEB-INF/classes directory. The BookSerialize.jsp is here:
    <%@ page language="java" import="java.beans.XMLEncoder, java.beans.XMLDecoder, java.io.*"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:html locale="true">
    <head>
    <html:base/>
    <title><bean:message key="index.title"/></title>
    </head>
    <body bgcolor="white">
    <h2>Book Serialization</h2>
    <%
    Book book = new Book();
    book.setTitle("A great Book about Struts");
    book.setPages(100);
    out.println("<member>First Title: " + book.getTitle() + "</member>");
    try {
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("/Sample.xml")));
    encoder.writeObject(book);
    encoder.close();
    } catch(Exception ex) {
    out.println(ex);
    book.setTitle("A great Book about Struts, Second Edition");
    out.println("<member>Second Title: " + book.getTitle() + "</member>");
    try {
    XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream("/Sample.xml")));
    book = (Book) decoder.readObject();
    decoder.close();
    } catch(Exception ex) {
    out.println("<h1>" + ex + "</h1>");
    out.println("<member>Third Title: " + book.getTitle() + "</member>");
    %>
    </body>
    </html:html>
    I also get the same error when deploying and (trying to) run on the J2EE 1.3.1 server.
    So far, I just used JSP pages working with beans (usebean tag). Is it possible at all to just do a
    MyClass myObject = new MyClass();
    within a JSP page, if MyClass.class is in the WEB-INF/classes of the web application?
    Is there any kind of import missing? Book.class is in the default package, so i can't state it in the page directive/import parameter of the JSP page...
    any advice?

    I think, I got it: you have to use package names for your classes and avoid the default package. After I used a package name, it was possible to instantiate the object ....

Maybe you are looking for