Struts actionform and checkboxes

hi!
I'm having trouble creating an actionform for a jsp that i have. Basically, my jsp lists files which have their corresponding checkboxes. The user can click multiple checkbox representing the files he wants to download. On clicking the download button, it submits it to my DownloadAction.
My problem is that only the first checkbox is stored in my actionform.
here's my actionform:
package mybeans;
import org.apache.struts.action.ActionForm;
import java.util.*;
public class FilesForm extends ActionForm
    Vector files = new Vector();
    String file = null;
    public String getFile() {
         System.out.println( "getting file" );
         return file;
    public void setFile( String string ) {  
         System.out.println( "setting file" );      
         file += string + ",";
         files.add( string );
    public Vector getFiles() {
         return files;
}my jsp is a bit big. here's the form part:
<html:form action="/download">
  <table>
    <tr>
      <td><input type="checkbox" name="file" value="someDynamicID"></td>
      <td>filename</td>
    </tr>
  ...more files here...
  </table>
</html:form>Thanks in advance!

Make your setter take a String[] argument and your getter return a String[] argument (I think List or Set might also work).

Similar Messages

  • Struts ActionForm and Model Objects design

    I've managed to make a pretty nice model with persistence managed by hibernate logic encapsulated in DAO's.
    But now Ive reached the web layer and I'm with struts, and I'm kind of stuck so I would love to hear some suggestions.
    How should I create ActionForms without duplicating the model state in ActionForm classes?
    Right now, my model implements ActionForm, which is tight coupling .
    But this increases maintenability.
    Other suggestions?

    It is a very bad idea to have your model implement ActionForm, for the reason you mentioned -- tight coupling. When you do that, you are tied to a web application; and, more specifically, Struts. "Best practice" says you need to duplicate a bit of your model in your ActionForm (Jakarta Commons BeanUtils makes this painless). As you probably know, the ActionForm should correspond to the form being displayed in the browser; each HTML form element should have a corresponding property in your ActionForm class. These properties might come from various parts of your domain model, so this gives you a place to muster them all together. I use an initXXXAction to populate the ActionForm, if needed, before display and a completeXXXAction to process the users input after they submit (although I'm thinking about switching to one of the DispatchAction flavors). Also, if the idea of maintaining the ActomForm classes is a hang-up, I'd suggest looking into the DynaXXX classes.
    Just to re-iterate, having your model implement ActionForm is BAD.

  • UIX and Struts ActionForm

    Hi,
    Can I use Struts ActionForm and ADF UIX?
    Thanks

    The "Simple Hello World sample using ADF UIX and JDeveloper 10g Preview" application integrates Struts with ADF UIX.
    http://jjacobi.blogspot.com/2003_11_30_jjacobi_archive.html
    Simple ADF UIX User Input Application
    http://www.oracle.com/technology/products/jdev/howtos/10g/adf_uix_userinput_ht/index.html

  • ActionForms and Actions

    I have managed to make a console extension for my custom authentication provider. But there is one problem - how to handle submitted form data. Currently there is no quality tutorial at weblogic sites :( I found some but there are some steps skipped!
    I only know that I have to make Struts ActionForms and Actions. But I really do not know how.
    Could you please help me.
    Thanks a lot.

    Enyone pleeeeeeeeease.
    I find lot of contrary examples at web, but there are some ideas i could use. I only do not know how to make struts-auto-config-xxx.xml file. There are no manual for it :-(
    Help please.

  • Struts ActionForm variable values in JSP

    I've tried to get variable values from a Struts ActionForm. I know that I can use Struts's bean tags, but can't figure out correct syntax or may there's some thing else to discover.
    I'm trying something like:
    <bean:define id="atr" name="MyActionForm" property="attribute"/></address>
    <p><%=atr%></p>
    And my struts-config look like:
    <form-bean name="MyActionForm" type="sth.MyActionForm"/>
    And the ActionForm is like:
    private String attribute;
    public String getAttribute() { ... }
    public void setAttribute(String attribute) {...}
    What may be wrong?
    Edited by: aproppon on Sep 26, 2007 9:46 AM

    I've tried with <bean:write... but since I catch exception saying MyActionForm can't be found in any scope. As far as I'm aware I've set request scope like:
    <action input="/jsp/something.jsp" name="MyActionForm" path="/jsp/myAction" scope="request" type="sth.MyAction">
    <forward name="success" path="/jsp/index.jsp"/>
    <forward name="failure" path="/jsp/something.jsp"/>
    </action>
    Edited by: D.A.R. on Sep 26, 2007 12:09 PM

  • Struts ActionForm bean retuning null values

    Hello friends,
    I am new to struts framework, I am trying a simple application which gets form details from user store it in ActionForm and showing in a jsp. Now the problem is when i try to get the bean values form the Action form it is returning only null values. but the values i entered in <html:form> is getting stored in the ActionForm.
    I am very much confused with this problem.Your help is greatly appreciated
    regards,
    Muthu

    r035198x wrote:
    I'm not too sure about this but I think struts questions are not all that welcome in this forum.
    Better try the dedicated struts forum at Apache.They're not per definition forbidden here, but it's just merely that you will have more chance to meet real Apache Struts experts at a Apache Struts forum instead of a general Sun Servlet forum, let alone Sun JSP/JSTL or Sun JSF forum.

  • Struts, beans, and unique IDs

    Hi,
    I'm trying to capture info from a web form using Struts, and I have a ActionForm (bean?) for that. When submitted (or instantiated - I don't know the details of how or when exactly it's being created), I want that bean to somehow get assigned a uniqueID so I could locate it easily in a database later.
    Where and when should I be doing this? Is it in the action class after the form has been submitted that I should assign ID to the bean (bean.setID(generatedInt); - but that's not good practice, I think), or inside the bean in its constructor? Or maybe there's a simple and clean way Struts can do this?
    And generally, is there good info on how and when the bean is being created by Struts? From Struts docs I got an idea of a bean representing a form through which the data is being submitted. Is this so?

    There are beans and then there are beans. They are used for many purposes.
    Struts ActionForm beans are used to gather together and validate the data from a JSP page (or some other view) and present it to the Action. Those are the beans they were probably talking about in the struts docs.
    Your business logic for the most part should be stored in different beans from these ActionForm beans.
    Database properties don't always correspond directly to all the fields on a form and vice versa. The whole point is that these business beans are your model - they should not in any way be affected by the view.
    On assigning Ids - my approach would be to have it in your business layer, rather than in the action class. That would mean that the beans could be usable outside of struts. Each individual class should be responsible for getting its id - ideally the first time it is saved.
    Just my 2 cents,
    evnafets

  • Is it possible to have sorting by group and checkboxes in the same ALV

    Hi there,
    Does anyone know whether it is possible to have sorting and group on one field in ALV and checkboxes set on another field in ALV?
    eg.
    Fieldname
    ===========
    Name----
    Text
    Allowance----
    Numeric -> Sort & Group
    Verified----
    Checkbox
    How do I code it if it is possible to have grouping and check box all in one ALV.  Meaning I want some data that are the same to merge using sort, while still having the checkbox available for my other field (Verified).
    Thanks in advance.
    Lawrence

    hi,
    GROUP BY clause is used on database tables with select statement.
    sort is used on internal tables.
    can u clearly explain y u need group by and sort on the same field.
    if u are extracting from dbtable using grou by clause on a field, then no need to sort it again.
    if u want sort u can do it by giveing "sort itab by field". thats not a problem.
    now coming to check box.instead of using SLIS type field catalog, u use LVC type.
    in LVC_S_LAYO, u can fine box_fname.
    while defining layout, u declare a variable of type LVC_S_LAYO
    AND GIVE BOX_FNAME = internal table field name

  • How is the processing speed while using struts,spring,and JSF framework

    Hi friends,
    As per earlier technology like Servlets,I mean that there would have much more performance speed than other new technologies like JSP,struts,spring and hibernate framework.Because,in new technologies,flow of processings implicitly via MVC2 basis will probably much more time than older one.
    Total goal is only for attaining MVC2 or any other purpose?
    Please clarify my doubt?
    With Regards,
    Stalin.G

    Home grown applications have a problem in that as more and more features are added, it becomes increasingly impossible to maintain the application and enhance it. This is especially true when the original programmers leave the company. A framework provides a standard design approach that other programmers can hopefully more easily pick up.
    A lot of work has gone into creating these frameworks and they have been used in web sites that have millions of hits from users per day. They have high preformance. Of course, programmers can still write bad code in them that slows down the system. I believe anyone using these frameworks should study them well before using them (such as reading books on them).

  • COMMIT problem in TopLink, Struts, JSP and ADF Databinding sample

    In the sample Developing a J2EE Application using TopLink, Struts, JSP and ADF Databinding,
    I followed all the steps to build a department browse page and a edit page.
    But when I get to Step number 23 in "Create a JSP to Edit Departments" I have a problem with the commit.
    Only after I make a change in the form and click the sumbit button, the commit and rollback buttons become active. And After I click the commit button the data gets commited to the database but the page inofmation changes to the very first department record, not the current one.
    How do I make those buttons active with out the extra click on the submit?
    After I click the commit button, how do I keep the current data on the screen?
    Thanks for you help.

    Shay,
    Thanks for the reply.
    For #1, I was able to do the following and get away with not having to press submit first. I just removed the bindings for disable. I hope that does not cause any problems?
    <input type="submit" name="event_Commit" value="Commit" />
    <input type="submit" name="event_Rollback" value="Rollback" />
    For #2, How I add an action on an HTML button? My UIModel.xml for the edit department page currently has two actions on it. Commit and RollBack. Is it linked through the "name" attribute of the input tag?

  • Struts Actions and events in one jsp?!

    Hello,
    I have a problem with Struts actions and events in a jsp.
    It is a search page and when the user clicks the search button I trigger an event and when the user clicks on a link in the result table (same page) I use an action that opens a new detail jsp. The first search query works well, I get a result, open the detail page, go back (using an action).
    Then I start a new search, but struts tries to open the detail page. While debugging I found out, that struts apparantly has no action or event. Why does it work at first time?
    Any ideas?
    Thanks in advance
    Britta

    Thanks for answer,
    I work with actions AND events. I think that`s the problem. When I go back from detail page to search page I use a custom DataForwardAction class with the following method:
    public void onCancel(DataActionContext ctx)
    DCBindingContainer bc = ctx.getBindingContainer();
    HttpServletRequest request = ctx.getHttpServletRequest();
    WebUtils.setSession(request);
    String ziel = request.getParameter("ziel");
    JUCtrlActionBinding action = (JUCtrlActionBinding) bc.findCtrlBinding("Rollback");
    action.doIt();
    try
    ctx.setActionForward(ziel);
    catch (Exception e)
    ctx.setActionForward("liste_freig");
    Ziel has the correct value ("search") and I think the struts config is also correct:
    <action path="/material" type="view.actions.materialAction" className="oracle.adf.controller.struts.actions.DataActionMapping" parameter="/material.jsp" name="DataForm">
    <set-property property="modelReference" value="generalUIModel"/>
    <forward name="liste_freig" path="/liste_freig.do"/>
    <forward name="liste_angelegt" path="/liste_angelegt.do"/>
    <forward name="list_bewertet" path="/list_bewertet.do"/>
    <forward name="liste_abgelehnt" path="/liste_abgelehnt.do"/>
    <forward name="liste_onhold" path="/liste_onhold.do"/>
    <forward name="search" path="/search.do?action=search"/>
    </action>
    But when I get back from material page to search page (the first time it works). The location pathname is material.do not search.do When start a new search the material page opens, not, as desired, the search page with new results.
    Search Action:
    public class searchAction extends DataForwardAction
    public searchAction()
    protected void prepareModel(DataActionContext ctx) throws Exception
    HttpServletRequest request = ctx.getHttpServletRequest();
    DataActionMapping acmap = ctx.getActionMapping();
    DCBindingContainer bc = ctx.getBindingContainer();
    WebUtils.setSession(request);
    JUCtrlActionBinding action = (JUCtrlActionBinding) bc.findCtrlBinding("delSearchQuery");
    action.doIt();
    String sEvent=null;
    try
    sEvent=request.getParameter("event");
    catch (Exception e)
    sEvent=null;
    if (sEvent==null)
    if (request.getParameter("action") != null)
    if (request.getParameter("action").equals("material"))
    Number mat_no=new Number(request.getParameter("MaterialNumber"));
    Number userId=new Number(WebUtils.getUserId(request));
    bc = ctx.getBindingContainer();
    action = (JUCtrlActionBinding) bc.findCtrlBinding("prepareMaterial");
    ArrayList arrayList= new ArrayList();
    arrayList.add(0,mat_no);
    arrayList.add(1,userId);
    action.setParams(arrayList);
    action.doIt();
    ctx.setActionForward("material");
    if (request.getParameter("action").equals("material_datasheet"))
    ctx.setActionForward("material_datasheet");
    super.prepareModel(ctx);
    public void onSearch(DataActionContext ctx)
    DCBindingContainer bc = ctx.getBindingContainer();
    HttpServletRequest request = ctx.getHttpServletRequest();
    WebUtils.setSession(request);
    ctx.setActionForward("search");
    Struts config:
    <action path="/search" className="oracle.adf.controller.struts.actions.DataActionMapping" type="view.actions.searchAction" name="DataForm" parameter="/search.jsp">
    <set-property property="modelReference" value="searchUIModel"/>
    <forward name="search" path="/search.do?action=search"/>
    <forward name="material" path="/material.do?action=material"/>
    <forward name="material_datasheet" path="/material_datasheet.do?action=material_datasheet"/>
    </action>
    I think it`s a Struts bug. Or is there something I don`t see?

  • Commandlink and checkbox in a region(.jsff).

    Hi all,
    I have a commandlink and checkbox in a region(.jsff).
    when i tried to call a method using propertychangeListener or Actionlistener ..
    methosd is not calling ...
    Plase give any solution...

    Hi,
    not enough information - sorry
    Frank

  • Integrating Struts, Tiles, and JavaServer Faces

    I have tried some sample applications in jsf. They are working properly. Basically, our application is based on struts. We fee that that it will be difficult to convert struts based application into jsf. So we plan to integrate jsf components into struts application. I found a site http://www.ibm.com/developerworks/library/j-integrate/ where jsf-struts integration material has been given. For this integaration, struts-faces.jar is required. when i try to start the server after struts-faces-1.3.8.jar placed in Tomcat 5.5\common\lib folder, server is not started properly. I have found struts-faces-1.3.8.jar in struts-1.3.8-lib. Should I user struts-faces.jar? if it is so, Where to find struts-faces.jar Please provide a solution for this problem.

    Wow, Srikanth. What a great contribution! I'm right at the begining of the design phase of a project that will hopefully go live in March and while I had already settled on a Tiles/Struts approach, I was really wanting to bring in JSF as well. I'm glad to see that someone is actively working on the integration components. I hope that the code modifications you propose make it into the Struts-Faces libraries soon.
    One question. While I've been deveolping J2EE webapps for a couple of years now,
    I'm still a little new to the Struts/Tiles arena. After reading your article at IBM developerWorks I wasn't able to ascertain whether or not what you proposed worked with the idea of individual controllers for each tile, which is a pattern that my project will need to adopt (I read about it in the short article here - http://www.theserverside.com/resources/article.jsp?l=Tiles101).
    Can you shed some light on the subject? Will the modifications you proposed allow Tiles to continue to work in that fashion?
    -Matt Welch
    Hi,
    Currently JSF, Struts and Tiles cannot work together
    out of the box.
    Craig McClanahan has come up with Struts-Faces which
    lets you integrate Struts and JSF. This is ideal for
    projects who want to protect their code investment in
    Struts and also want to take advantage of JSF once it
    is final.
    Unfortunately if you are also using Tiles, this is not
    possible because of some showstoppers on your way. I
    started on this venture a while back and ran into the
    same problems and decided to write some code - on top
    of Struts-Faces and was pretty successful.
    I am sharing this knowledge with the rest of you with
    this article of mine on IBM developerWorks
    http://www-106.ibm.com/developerworks/library/j-integra
    e/
    As already pointed out in this forum earlier, this
    article covers the steps to integrate the three and
    provides complete source code and also a working
    example.
    Hope you will find the article and the code useful.
    Thanks,
    Srikanth

  • Struts Diagram and CVS Problems

    We're having a difficult time with the StrutsPageFlow.oxd_struts and CVS. Anytime a developer makes a change to the Struts diagram and commits the struts-config.xml file, the StrutsPageFlow.oxd_struts file also gets committed. When a different developer updates the struts-config.xml file the StrutsPageFlow.oxd_struts file has a conflict on just about every item. We're also encountering this on our *.jpr and bc4j.xcfg files.
    JDeveloper 10g is stealing a lot of our time as we're having to manually work around a lot of CVS conflicts on files that are not shown in the project but associated with project files like the struts-config.
    Anyone else having CVS issues with these "behind-the-scene" files?

    Hi Jason,
    Unfortunately, this is a known issue. The only workaround we can suggest for struts at the moment is using an exclusive editing mode. Whenever a developer needs to modify the struts diagram, he should issue a cvs edit. Other developers should use the "List Editors" functionality in JDev to check whether someone is currently editing the file.
    We're working on resolving these team development issues in the 10.1.3 release.
    Thanks,
    Brian

  • Alv and checkboxs

    Guys,
    Ive a problem with a ALV and checkboxs. i have one with column type checkbox, i need mark rows and take them afterward using a button (in ALV) but rows arent marked when i use button. i have seen that it only happend when i use double click in grid (alv).
    How could i use only button after marked my rows ?????
    Thanks

            wa_fieldcat-edit = 'X'.
            modify i_fieldcat from wa_fieldcat index sy-tabix.
    * Form f_alv_edit_oruser                                               *
    * Form for display alv                                                 *
    form f_alv_edit_oruser.
        call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            it_fieldcat                 = i_fieldcat[]
            is_layout                   = pt_grplayout2
            i_callback_program          = 'YSCCU0007'
            i_callback_html_top_of_page = p_header
            i_callback_user_command     = v_user_command1
            it_events                   = i_events[]
          tables
            t_outtab                    = i_yscchdr.
    endform.                                 " F_alv_edit_oruser
    * Form  f_user_command1                                                *
    * This form will handle the user command from fm REUSE                 *
    form f_user_command1 using p_ucomm type sy-ucomm
                         rs_selfield type  slis_selfield.
      data p_ref1 type ref to cl_gui_alv_grid.      "<<<
      call function 'GET_GLOBALS_FROM_SLVC_FULLSCR' "<<<
        importing                                   "<<< 
          e_grid = p_ref1.                          "<<
      call method p_ref1->check_changed_data.   " <<<<
      case p_ucomm.
        when '&DATA_SAVE'.
       endcase.
      rs_selfield-refresh = c_x.             " Grid refresh
    endform.                                 " F_user_command1

Maybe you are looking for

  • Payment Run is cancelled

    Hi Gurus I am trying to do APP Run , after entering parameters , the proposal is created and now when I am trying to do the Payment Run it is giving message as payment run is can celled and the reason given as document number range is missing for tha

  • In the dialogue window of "Manage Search Engine List," the "Restore Defautls" button is grayed out!

    Hi, I use Firefox 6.0.1 on Windows 7. I installed '''Free Desktop Clock 2.37''' from Drive Software, and then Firefox was hi-jacked, though I carefully chose the custom installaion. Edit: Free Desktop Clock itself does not hi-jack Firefox. It's anoth

  • Split Output from Select into 2 different Cols

    Hi, I am new to oracle dev. Env Oracle 10g R2 I need a help with the following. I have a select query that returns comma separated values. Column LIST1 in table svp_1. This needs to hold that data returned by the select query. Datatype of Column LIST

  • Sales Order Costing using prod version

    Hi Guru, My client use MTO and have prod version 1000 & 2000.  When I create SO and choose prod.version 1000,  prod.order created using BOM/Routing in prod.version 1000, so the prod order cost plan. But in costing SO, prod version 2000 is use as base

  • How to match custom profile of PMW-350K and Canon XF300

    Not exacctly a Premiere Pro question, but neither does it belong in the Lounge. We will be shooting the Heineken Regatta on Sint Maarten in March. We have two cameras, a Canon XF300 and a Sony PMW-350K with the standard 16x Fujinon lens. What is the