Constructor initalization lists

I come from C++ and wonder how I can initialize members of subclasses before calling the parent constructor:
e.g.
class MyParent {
  int a;
  public MyParent(int a) {
    this.a=a
    initSomeStuff();
  protected void additionalnitialization() {
class MyClass extends MyParent {
  int b;
  int c;
  public MyClass(int a, int b) {
    super(a); // I must call this first!
    this.b = b;
  @Override
  protected void additionalnitialization() {
    // when this function is called a is NOT initialized yet!
    c = a+b;
}How can I initialize b before calling the super constructor?
In C++ i would use initialization lists like this (pseudo-code):
class MyClass extends MyParent {
  int b;
  int c;
  public MyClass(int a, int b) : this.b(b) {
    super(a); // at this time b is already initialized through the initalization list
}what is the java-way to do this?
Edited by: java-noob-from-cpp on Feb 9, 2009 1:57 PM

so what do you java-guys use to workaround this?
I'll try to provide a better example, wher I would like to use this kind of functionality: from the last posts I already know, that this won't work, but I hope that this example could clarify this.
I have one parent widget that has a lot of common functionality and it just wants to allow it's children to provide one distinct widget.
abstract class BloatedParent {
  someParams;
  public BloatedParent(someParams) {
    this.someParams = someParams;
    createWidgets();
    layoutWidgets();
  private createWidget() {
    Container container = new Container();
    container.add(new Toolbar);
    // I should NOT do this in java, I know: but what else?
    container.add(getCustomWidgetFromChild());
    container.add(..);  
  protected abstract Widget getCustomWidgetFromChild();
class Child1 extends BloatedParent {
   Object1 object1;
   Child1(someParams, object1) {
     super(someParams);
     this.object1 = object1;
   protected Widget getCustomWidgetFromChild() {
      // e.g. build some fancy Panel Widget and return it
      // will of course NOT work, because this.object1 is not assigned yet
      return new FancyPanel(object1.getTitle(), object1.getName(),  ..);
class Child2 extends BloatedParent {
   Object2 object2;
   Child2(someParams, object2) {
     super(someParams);
     this.object2 = object2;
   protected Widget getCustomWidgetFromChild() {
      // e.g. build a nice Image Widget
      // will also NOT work...
      return new NiceImage(object2.getFilename(), object2.getHeight(),  ..);
}what I could do of course, is to move all function calls from the constructor to a method called initialize() and then every child just had to call this method, after it has set its constructor args, like this:
abstract class BloatedParent {
  someParams;
  public BloatedParent(someParams) {
    this.someParams = someParams;
  // children MUST call this at the end of their constructors!
  protected initialize() {
     createWidgets();
     layoutWidgets();
class Child1 extends BloatedParent {
   Object1 object1;
   Child1(someParams, object1) {
     super(someParams);
     this.object1 = object1;
     initialize();
}but that just feels sooo wrong

Similar Messages

  • List() in java.io.file

    Hallo everybody!
    Can someone solve a little problem for me?
    I want to list files and directories in a directory. If one of the files is a dirctory I want to put an "/" to the end of it. I works well if I list the current directory but not if I try to list a path like c:\temp.
    Here is my code :
    public class Lista {
    //int i;
    int i = 0;
    //File Katalog;
    // constructors
    public Lista() {
    usage();
    public Lista(String[] l_files) {
    list_files(l_files);
    // methods
    // method called if 1 argument is passed to main
    private void list_files(String[] lf) {
    // first check if katalog is a file
    File katalog = new File(lf[0]);
    // String c = new String(lf[1]);
    if (katalog.isFile()) {
    System.out.println(katalog + " is a file");
    System.exit(1);
    // check if katalog exists
    if (katalog.exists()) {
    String[] en_lista = katalog.list();
    while (i < en_lista.length) {
    File f = new File(en_lista);
    if (f.isDirectory() == true) {
    //if (f.isFile()) {
    //f.getParent();
    System.out.println(f + "/");
    else {
    System.out.println(f);
    i++;
    else
    System.out.println(katalog + " doesn't exist");
    // method called if no or more than 1 argument are passed to main
    private void usage() {
    System.out.println("\nusage : " + "\njava Lista directory");
    System.exit(0);
    public static void main(String[] args) {
    // depending on the number of arguments passed to main different constructors are called
    if (args.length < 1 || args.length > 2) {
    new Lista();
    else if (args.length == 1) {
    new Lista(args);

    **** example 1 ******
    Here it works as I want it to do
    java Lista . givs the output
    directory/ (the slash mark that it is a directory)
    Lista.class
    Lista.java
    **** example 2 ******
    If I list like below it doesn't work
    java Lista c:\temp givs the output
    directory
    file.txt
    (I want to have the slash in the end of the directory to mark it's a directory but it doesn't)

  • Undefined Constructor for Polygon

    Hello,
    I have a undefined constructor error message for polygon in Eclipse and I cannot figure out why.
    Initially I have this method and everything worked fine; public void drawing (Graphics g, List <int []> x_Points, List <int []>y_Points) {
              Graphics2D g2d = (Graphics2D) g;
              g2d.setColor(Color.blue);
              g2d.setStroke(new BasicStroke(1F));
              ArrayList<Polygon> list = new ArrayList<Polygon>();
               for( int p = 0; p < x_Points.size(); p++) {
                   list.add(new Polygon(x_Points.get(p),y_Points.get(p),x_Points.get(p).length));
                    }During the course of writing other methods, I found out that using List<List<Integer>> will be better than List<int []>, so I decided to modify the code above to:public void drawings(Graphics g, List <List<Integer>> x_Points, List <List<Integer>>y_Points) {
              Graphics2D g2d = (Graphics2D) g;
              g2d.setColor(Color.blue);
              g2d.setStroke(new BasicStroke(IF));
              ArrayList<Polygon> list = new ArrayList<Polygon>();
               for( int p = 0; p < x_Points.size(); p++) {
                   list.add(new Polygon(x_Points.get(p),y_Points.get(p),x_Points.get(p).size()));
                    } But I got this Error; The constructor Polygon(List<Integer>, List<Integer>, int) is undefined
    Thanks,
    Jona_T

    The polygon constructor you are using accepts arrays of ints, not Lists. I think it will work if you change it to:
    list.add(new Polygon(x_Points.get(p).toArray(new Integer[0]),y_Points.get(p).toArray(new Integer[0]),x_Points.get(p).size()));toArray converts the list to an array, which is what the Polygon constructor accepts, and the argument of an Integer array tells it to make an array of Integers instead of an array of Objects.

  • Initialising a list, with values - how to?

    Hi
    I want to create a list with some values already in it - how do you do this? I know the constructor is
    List<Integer> = new ArrayList<Integer>();
    but how would I create a new list already containing the following values at construction time?:
    [244753217,613613369,415120695,355142652,134856040,478060706,331972076, 532347366,600207262]
    Many thanks, Ron

    Hi
    Yes, but could you add all the numbers at once, and
    my question is really in regard to initialising the
    list in the first place!No it isn't. You think it is but it isn't.
    There is a constructor whereby you can feed ArrayList another Collection and it will add the items of that collection to it's own list when it is constructed.
    Of course you still have to initialize A collection at some point to do that. Which means in the end that you have to add items to a collection. So it all comes back to you really needing to do this at intialization and the answer is in the end you can't. But as I said you don't HAVE to do this and if you think you must you are mistaken.
    If you continue to insist that you MUST do this then please post some formatted code that explains why and we can point out the flaws in your thinking.

  • Thread safety: exposing "this" via a "static" reference  in constructor

    please consider:
    public class Foo  {
      public static List<Foo> list = new ArrayList<Foo>();
      public int i = 1;
      Foo() {
        Foo.list.add(this);
        i++;
        // ...... other stuff that does not effect "i"
    }Exiting, I want "i" to always be 2. But what if a thread got the reference to "this" from the static List before the constructor exited and did:
    ((Foo) Foo.list.get(0)).i++;Is the only solution a synchronized wrapper for "list"?
    Thanks.

    A synchronized wrapper is not sufficient:
    public static List<Foo> list = Collections.synchronizedList(new ArrayList<Foo>());This is because the list is now thread-safe, but what about the items in it?
    Look at your constructor:
    Foo.list.add(this);
    i++;Another thread could access the list in between the execution of these two lines and see the value of i before i is incremented.

  • Images not displaying.

    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.awt.geom.*;
    public class Game extends Applet implements Runnable, KeyListener {
         protected Thread thread, animation;
         private int i, keyVal, width, height, firstIndex, cellWidth, cellHeight, cellBorder;
        private double x, y, px, py, dx, dy, ddx, ddy, rate;
         private Image offscreenImage, background, images[];
         private BufferedImage redGuy;   //Create grafix objects to handle back buffering
           private BufferedImage[] drawingImage;
         private Graphics offscr;
        private boolean upPressed, downPressed, leftPressed, rightPressed, spacePressed;      //Keypressed variables
         public Game() { //Constructor (initalizes variables)
              thread = new Thread(this);  //Initalize thread, as new instance of our applet
              i = 0;           // Initalize our loop counter to 0
            x = 1;        // Initalize x coordinate to 1
            y = 1;        // Initalize y coordinate to 1
            px = 0;          // the previous x position    
              py = 0;      // the previous y position
              dx = 0;      // the change of x (delta x) -- speed of x
              dy = 0;      // the change of y (delta y) -- speed of y
              ddx = 10;     // the change of dx (delta delta x) -- acceleration of x
              ddy = 10;     // the change of dy (delta delta y) -- acceleration of y
              rate = 1000 / 30;  //Rate at which we'll make our thread sleep
                                  //the thread sleeping will give us our FPS                         
            //Initalize my keydown variables
            upPressed = false;
            downPressed = false;
            leftPressed = false;
            rightPressed = false;
            spacePressed = false;
            //Initialize array
            drawingImage =  new BufferedImage[7];
         public Image[] loadImageStrip(String filename,  int numImages, int cellWidth, int cellHeight, int cellBorder)
              Image [] images = new Image[numImages];
              MediaTracker mt = new MediaTracker(this);
              Image img = getImage(getDocumentBase(), filename);
              mt.addImage(img, 0);
              try {
                   mt.waitForID(0);
              } catch (InterruptedException ex) { /* Do nothing */ }
              int numCols = 1;//img.getWidth(this) / cellWidth;
              ImageProducer sourceProducer = img.getSource();
              for(int i = 0; i < numImages; i++) {
              images[i] = loadCell(sourceProducer ,((i%numCols) * cellWidth)+cellBorder,
              ((i/numCols) * cellHeight)+cellBorder,
              cellWidth - cellBorder,
              cellHeight - cellBorder);
              return images;
         public Image loadCell(ImageProducer ip, int x, int y, int width, int height) {
              return createImage(new FilteredImageSource(ip, new CropImageFilter(x, y, width, height)));
         public void init() {          //Equivalent of the Main method
              thread.start();          //Start the thread
           background = getImage(getDocumentBase(), "castle.jpg");
         addKeyListener(this);   //Makes our applet listen for pressed keys!
         //Create back buffer for page flipping
         width = getSize().width;          //Set width variable to size of screen
           height = getSize().height;          //Set height variable to size of screen
           offscreenImage = createImage(width, height);     //Create off screen image (back buffer)
           offscr = offscreenImage.getGraphics();
           //Put this next line here so that it only gets drawn once.
           offscr.setColor(Color.black);
           offscr.fillRect(0,0, width, height);     //Draw black background rect.
           images = loadImageStrip("stick_low_punch.bmp", 5, 60, 300, 3);
         public void run() {     //This method is where we will handle our main game loop
              //Infinte loop (to refresh our screen and handle game stuff)
        while(true)
             px = x;          //Sets previous x
              py = y;          //Sets previous y
          i++;     //Increments I (so we can see how many times this loop has ran)
          processKeyPressedEvents();  //Processes any key events that've happened
          processKeyReleasedEvents();
          detectCollide();     //Runs our detect collision code
          repaint();          //Repaints the screen to update stuff.
          try {               
            thread.sleep((int)rate);          //Tells the thread to shut down for 33 milliseconds
                 } catch (InterruptedException e) { }
      //Paint method.  Paints everything to the applet for us.
           public void paint(Graphics g)
                offscr.setColor(Color.black);     //Set Color to black
                offscr.drawImage(background, 0, 0, this);
            offscr.drawString("i = "+i,10,20);  //Shows value of i at Location 10, 20
            offscr.drawString("Key = " + keyVal, 70, 20);   //Draw key value
            for(int q = 0; q < images.length; q++) {
                   offscr.drawImage(images[q], (int)x, (int)y , this);
                   offscr.drawString("Q = " + q, 70, 40);
                g.drawImage(offscreenImage, 0, 0, this);
           public void update(Graphics g)
             paint(g);
         public void keyPressed(KeyEvent e) {
              keyVal = e.getKeyCode();
              switch(keyVal) {
                   case KeyEvent.VK_UP : upPressed = true;
                   break;
                   case KeyEvent.VK_DOWN : downPressed = true;
                   break;
                   case KeyEvent.VK_LEFT : leftPressed = true;
                   break;
                   case KeyEvent.VK_RIGHT : rightPressed = true;
                   break;
         public void keyReleased(KeyEvent e) {
              keyVal = e.getKeyCode();
              switch(keyVal) {
                   case KeyEvent.VK_UP : upPressed = false;
                   break;
                   case KeyEvent.VK_DOWN : downPressed = false;  
                   break;
                   case KeyEvent.VK_LEFT : leftPressed = false;   
                   break;
                   case KeyEvent.VK_RIGHT : rightPressed = false;
                   break;
         public void keyTyped(KeyEvent e) {
         //I don't need this method for now.     
           public void detectCollide() {
          /*  Collision detection for borders of window */
          if(x <=0) { x = 1;}       //Detect x at left
          if(y <=0) { y = 1;}       //Detect y at top
          if(x >=getSize().width-50) { x = getSize().width-50;}   //Detect x at right
          if(y >=getSize().height-180) { y = getSize().height-180;}   //Detect y at bottom
         public void processKeyPressedEvents() {      //This will handle the events if a key is pressed.
          /* This is an IMPORTANT method.
           *not only does it make for smoother movement
           *but it also allows us to press and
           *hold multiple keys.  Without this
           *method, holding a key down would
           *be interrupted by the next key pressed
          if(upPressed == true) {
           y -= ddy;  dy -= ddy;
          if(downPressed == true) {
                y+= ddy; dy += ddy;
          if(leftPressed == true) {
                x-= ddx; dx -= ddx;
          if(rightPressed == true) {
                x+= ddx; dx += ddx;
      public void processKeyReleasedEvents() {
           if(upPressed == false) {while(dx < 0) {dy += ddy; }}
          if(downPressed == false) {while(dy > 0) {dy -= ddy; }}
          if(leftPressed == false) {while(dx < 0) {dx += ddx; }}
          if(rightPressed == false) { while(dx > 0) {dx -= ddx; }}
    }For some reason my image (the strip image) is not displaying. It's loading, but nothing is being shown.
    If anyone can figure out why, please let me know, I've been beating my head off the wall for about 2 weeks now.
    Thanks,
    Brian

    I noticed in your code you are trying to load a bitmap image. I don't think Java is capable of using that
    image format yet.. Stick to using .jpg , .gif, .png

  • Generics in swing?

    Just wondering -- Are there any plans to use generics with swing classes? In particular, ListModel, TableModel, and (perhaps) TreeModel? After all, the default implementations of the first two must now be based on Vector<E> ...

    Practical answer: I'd settle for Swing being updated to use JFC collection classes instead of Vector,
    Hashtable and Dictionary...
    Theoretical Answer: So then you could pass your DefaultTableModel constructor a
    List<? extends List<Object>>. Woopdeedoo... For generics to rock, from the strong typing point
    of view, you should be able to have, say different classes for different columns, and have that checked
    at compile-time. That's way beyond what generics can or ever will do.
    Positive Answer: well, generics have peeped out in a few places (like Class and Comparable), maybe
    this is the kick-in the pants that will get Swing to be updated a bit. It may not help, but it couldn't hurt...

  • Hirarchy of interactive report

    Hi Gurus,
    Please tell me what is the meaning of "Hirarchy of an interactive report"?

    HI
    refer this code.
    *&  Include           Z_TABLE_DISPLAY
    VERSION 2
    Code from François Henrotte (EPONA Solutions)
                                http://www.eponasolutions.com
                                Belgium
    Please keep reference !
    HOW TO
    Display an ALV grid :
    CALL METHOD lcl_table_display=>display_grid( 'tabname' ).
    Display a hierarchical list with header and detail :
    CALL METHOD lcl_table_display=>display_hier( in_header = 'table1'
                                                 in_detail = 'table2' ).
    Display a block list with two tables :
    CALL METHOD lcl_table_display=>set_block_mode( 'X' ).
    CALL METHOD lcl_table_display=>display_grid( 'table1' ).
    CALL METHOD lcl_table_display=>display_grid( 'table2' ).
    CALL METHOD lcl_table_display=>end_block_list( ).
    You never have to deal with field catalog of tables !!
    What if field catalog has to be changed anyway ?
    ob_table = lcl_table_display=>create_table( 'tabname' ).
    CALL METHOD ob_table->set_alv_fieldtext( in_field = field
                                             in_ftext = 'text' ).
    CALL METHOD lcl_table_display=>display_grid( 'tabname' ).
    type-pools: abap, slis.
      LCL_TABLE_DISPLAY DEFINITION
    class lcl_table_display definition.
      public section.
        class-methods: display_list importing in_tabname  type any,
                       display_grid importing in_tabname  type any,
                       display_hier importing in_header   type any
                                              in_detail   type any
                                              in_level    type i optional,
                       set_block_mode importing in_mode type c,
                       set_block_text importing in_text type any,
                       end_block_list importing in_print
                                           type slis_print_alv optional
                                     exceptions display_error,
                       create_table
                         importing
                           in_tabname type tabname
                         returning
                           value(out_table) type ref to lcl_table_display
                         exceptions
                           create_error,
                       get_existing_table
                         importing
                           in_tabname type any optional
                           in_repid   type any optional
                           in_struc   type any optional
                         returning
                           value(out_table) type ref to lcl_table_display
                         exceptions
                           no_parameter
                           not_found,
                       refresh_objects.
        methods: constructor importing in_data type standard table
                             exceptions casting_error
                                        empty_fieldcat.
        methods: get_alv_fieldcat  returning value(out_fieldcat)
                                        type slis_t_fieldcat_alv.
        methods: set_table_name     importing in_tabname  type any,
                 set_alv_title      importing in_title    type any,
                 set_alv_fieldcat   importing in_fieldcat
                                         type slis_t_fieldcat_alv,
                 set_alv_fieldnoout importing in_field    type any
                                              in_noout    type c optional
                                              in_tech     type c optional,
                 set_alv_fieldedit  importing in_field    type any
                                              in_edit     type c optional,
                 set_alv_fieldtext  importing in_field    type any
                                              in_ftext    type any,
                 set_alv_fieldsum   importing in_field    type any
                                              in_dosum    type c optional,
                 set_alv_linebreak  importing in_field    type any,
                 set_alv_settings   importing in_settings type any,
                 set_alv_layout     importing in_layout   type any,
                 set_alv_print      importing in_print    type any,
                 set_alv_sorting    importing in_field    type any
                                              in_desc     type c optional
                                              in_group    type any optional
                                              in_subtot   type c optional,
                 set_alv_keys       importing in_level    type i
                                              in_key      type c optional,
                 set_alv_event      importing in_name     type any
                                              in_form     type any,
                 set_all_events.
      protected section.
        data: g_table_type type slis_list_type.
        data: g_title      type lvc_title,
              gt_fcat      type slis_t_fieldcat_alv,
              gs_sett      type lvc_s_glay,
              gs_layo      type slis_layout_alv,
              gt_sort      type slis_t_sortinfo_alv,
              gt_evnt      type slis_t_event,
              gs_prin      type slis_print_alv.
        class-methods: output_hierarchy exceptions display_error.
        methods: output_table importing mode type c
                             exceptions display_error,
                 output_list,
                 output_grid.
      private section.
        class-data: gt_table_obj   type table of ref to lcl_table_display,
                    g_header_table type ref to lcl_table_display,
                    g_detail_table type ref to lcl_table_display.
        class-data: g_variant_level type i.
        class-data: g_block_mode    type c,
                    g_block_text    type slis_text40.
        types: begin of ty_defin,
                 fieldname     type fieldname,
                 ref_tabname   type tabname,
                 ref_fieldname type fieldname,
               end of ty_defin.
        data: g_repid  type repid,
              g_struc  type tabname,
              g_table  type tabname.
        data: gt_data  type ref to data.
        data: gt_defin type table of ty_defin,
              g_level  type tabname.
        methods: init_block_list,
                 fill_fieldcat importing repid type repid
                                         struc type tabname
                                changing fcat  type slis_t_fieldcat_alv
                              exceptions no_definition,
                 get_definition importing repid type repid
                                          struc type tabname
                                 changing abap  type rsfb_source,
                 recursive_definition importing repid type repid
                                       changing abap  type rsfb_source,
                 map_structure importing source type any
                                changing destin type any,
                 get_default_variant changing out_variant type disvariant.
    endclass.                    "lcl_table_display DEFINITION
      LCL_TABLE_DISPLAY IMPLEMENTATION
    class lcl_table_display implementation.
      Display table in ALV list
      method display_list.
        data: l_object  type ref to lcl_table_display,
              l_tabname type tabname,
              l_found   type c.
        l_tabname = in_tabname.
        loop at gt_table_obj into l_object.
          if l_object->g_table = l_tabname.
            l_found = 'X'.
            exit.
          endif.
        endloop.
        if l_found is initial.
          l_object = lcl_table_display=>create_table( l_tabname ).
          if g_block_mode is initial.
            l_object->g_table_type = 4.
          else.
            l_object->g_table_type = 2.
          endif.
          call method l_object->set_all_events.
        endif.
        call method l_object->output_list.
      endmethod.                    "display_list
      Display table in ALV grid
      method display_grid.
        data: l_object  type ref to lcl_table_display,
              l_tabname type tabname,
              l_found   type c.
        l_tabname = in_tabname.
        loop at gt_table_obj into l_object.
          if l_object->g_table = l_tabname.
            l_found = 'X'.
            exit.
          endif.
        endloop.
        if l_found is initial.
          l_object = lcl_table_display=>create_table( l_tabname ).
          if g_block_mode is initial.
            l_object->g_table_type = 4.
          else.
            l_object->g_table_type = 2.
          endif.
          call method l_object->set_all_events.
        endif.
        if g_block_mode is initial.
          call method l_object->output_grid.
        else.
          call method l_object->output_list.
        endif.
      endmethod.                    "display_grid
      Display tables in ALV hierarchy
      method display_hier.
        data: l_tabnam1 type tabname,
              l_tabnam2 type tabname,
              lt_fcat1  type slis_t_fieldcat_alv,
              lt_fcat2  type slis_t_fieldcat_alv,
              ls_fcat1  type slis_fieldcat_alv,
              ls_fcat2  type slis_fieldcat_alv.
        l_tabnam1 = in_header.
        l_tabnam2 = in_detail.
        call method lcl_table_display=>get_existing_table
          exporting
            in_tabname = l_tabnam1
          receiving
            out_table  = g_header_table
          exceptions
            not_found  = 1.
        if sy-subrc ne 0.
          g_header_table = lcl_table_display=>create_table( l_tabnam1 ).
          if g_block_mode is initial.
            g_header_table->g_table_type = 1.
          else.
            g_header_table->g_table_type = 3.
          endif.
          call method g_header_table->set_all_events.
        endif.
        call method lcl_table_display=>get_existing_table
          exporting
            in_tabname = l_tabnam2
          receiving
            out_table  = g_detail_table
          exceptions
            not_found  = 1.
        if sy-subrc ne 0.
          g_detail_table = lcl_table_display=>create_table( l_tabnam2 ).
        endif.
      Set key fields
        if in_level is initial.
          lt_fcat1 = g_header_table->get_alv_fieldcat( ).
          lt_fcat2 = g_detail_table->get_alv_fieldcat( ).
          loop at lt_fcat1 into ls_fcat1.
            ls_fcat1-key = space.
            loop at lt_fcat2 into ls_fcat2
                            where fieldname = ls_fcat1-fieldname.
              ls_fcat2-key = space.
              ls_fcat2-key_sel = 'X'.
              ls_fcat2-tech = 'X'.
              modify lt_fcat2 from ls_fcat2 transporting key.
            endloop.
            if sy-subrc = 0.
              ls_fcat1-key = 'X'.
            endif.
            modify lt_fcat1 from ls_fcat1 transporting key.
          endloop.
          call method g_header_table->set_alv_fieldcat
            exporting
              in_fieldcat = lt_fcat1.
          call method g_detail_table->set_alv_fieldcat
            exporting
              in_fieldcat = lt_fcat2.
        else.
          call method g_header_table->set_alv_keys
            exporting
              in_level = in_level.
          call method g_detail_table->set_alv_keys
            exporting
              in_level = in_level
              in_key   = space.
        endif.
        call method output_hierarchy.
      endmethod.                    "display_hier
      Set block mode
      method set_block_mode.
        g_block_mode = in_mode.
      endmethod.                    "set_block_mode
      Set block text
      method set_block_text.
        g_block_text = in_text.
      endmethod.                    "set_block_text
      Create new table
      method create_table.
        data: l_object type ref to lcl_table_display.
        field-symbols: set_table_name
          exporting
            in_tabname = in_tabname.
      Default print options
        l_object->gs_prin-no_print_selinfos  = 'X'.
        l_object->gs_prin-no_coverpage       = 'X'.
        l_object->gs_prin-no_print_listinfos = 'X'.
        out_table = l_object.
      endmethod.                    "create_table
      Get existing table
      method get_existing_table.
        data: l_object  type ref to lcl_table_display,
              l_tabname type tabname,
              l_repid   type repid,
              l_struc   type tabname,
              l_found   type c.
        l_tabname = in_tabname.
        l_repid   = in_repid.
        l_struc   = in_struc.
        if l_tabname is initial.
          if l_repid is initial and
             l_struc is initial.
            raise no_parameter.
          else.
          Get last existing table with same definition
            loop at gt_table_obj into l_object.
              if l_object->g_repid = l_repid and
                 l_object->g_struc = l_struc.
                l_found = 'X'.
                exit.
              endif.
            endloop.
          endif.
        else.
        Get last existing table with same name
          loop at gt_table_obj into l_object.
            if l_object->g_table = l_tabname.
              l_found = 'X'.
              exit.
            endif.
          endloop.
        endif.
        if l_found is initial.
          raise not_found.
        else.
          out_table = l_object.
        endif.
      endmethod.                    "get_existing_table
      Create table display
      method constructor.
        data: l_object type ref to lcl_table_display.
        data: ls_data  type ref to data.
        data: ob_desc  type ref to cl_abap_structdescr.
        data: l_found  type c,
              l_absol  type char200,
              l_repid  type repid,
              l_struc  type tabname.
        field-symbols:  type any.
      Get data and store it into attribute
        create data me->gt_data like in_data.
        assign me->gt_data->* to .
    = in_data.
      Get global data definition
        create data ls_data like line of  ).
        endcatch.
        if sy-subrc = 1.
          raise casting_error.
        endif.
      Get program name and main type used to define table
        l_absol = ob_desc->absolute_name.
        split l_absol at 'TYPE=' into l_repid l_struc.
        shift l_repid up to '='.
        shift l_repid.
        check l_struc np '%_*'.
      Set attributes
        me->g_repid = l_repid.
        me->g_struc = l_struc.
        me->g_table = l_struc.
        replace 'TY' with 'WT' into me->g_table.
      Field catalog
        call method lcl_table_display=>get_existing_table
          exporting
            in_repid  = l_repid
            in_struc  = l_struc
          receiving
            out_table = l_object
          exceptions
            not_found = 1.
        if sy-subrc = 0.
          me->gt_fcat = l_object->get_alv_fieldcat( ).
          call method set_table_name
            exporting
              in_tabname = me->g_table.
        else.
          call method fill_fieldcat
            exporting
              repid = l_repid
              struc = l_struc
            changing
              fcat  = me->gt_fcat.
          if me->gt_fcat is initial.
            raise empty_fieldcat.
          endif.
        endif.
      Keep list of tables
        append me to gt_table_obj.
      endmethod.                    "constructor
      Output list
      method output_list.
        call method output_table
          exporting
            mode = 'L'.
      endmethod.                    "output_list
      Output grid
      method output_grid.
        call method output_table
          exporting
            mode = 'G'.
      endmethod.                    "output_grid
      Output table
      method output_table.
        data: l_object type ref to lcl_table_display.
        data: ls_vari  type disvariant.
        field-symbols: type standard table.
    assign me->gt_data->* to .
    if not g_block_mode is initial.
    read table gt_table_obj into l_object index 1.
    if sy-subrc = 0.
    if l_object->g_table = me->
    g_table.
              call method init_block_list.
            endif.
          endif.
        endif.
      Get default user variant
        call method get_default_variant
          changing
            out_variant = ls_vari.
      Display table contents
        if mode = 'G'.
          call function 'REUSE_ALV_GRID_DISPLAY'
            exporting
              i_callback_program = me->g_repid
              i_grid_title       = me->g_title
              i_grid_settings    = me->gs_sett
              is_layout          = me->gs_layo
              it_fieldcat        = me->gt_fcat
              it_sort            = me->gt_sort
              i_save             = 'U'
              is_variant         = ls_vari
              it_events          = me->gt_evnt
              is_print           = me->gs_prin
            tables
              t_outtab           =
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    raise display_error.
    endif.
    call method refresh_objects.
    else.
    if g_block_mode is initial.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_callback_program = me->g_repid
    is_layout = me->gs_layo
    it_fieldcat = me->gt_fcat
    it_sort = me->gt_sort
    i_save = 'U'
    is_variant = ls_vari
    it_events = me->gt_evnt
    is_print = me->gs_prin
    tables
    t_outtab =
    exceptions
    others = 0.
    if sy-subrc <> 0.
    raise display_error.
    endif.
    call method refresh_objects.
    else.
    call function 'REUSE_ALV_BLOCK_LIST_APPEND'
    exporting
    is_layout = me->gs_layo
    it_fieldcat = me->gt_fcat
    i_tabname = me->g_table
    it_events = me->gt_evnt
    it_sort = me->gt_sort
    i_text = g_block_text
    tables
    t_outtab =
    exceptions
    program_error = 1
    maximum_of_appends_reached = 2
    others = 3.
    if sy-subrc <>
    0.
              raise display_error.
            endif.
          endif.
        endif.
      endmethod.                    "output_table
      Output hierarchy
      method output_hierarchy.
        data: l_object type ref to lcl_table_display.
        data: lt_fcat  type slis_t_fieldcat_alv,
              lt_sort  type slis_t_sortinfo_alv,
              ls_fcat  type slis_fieldcat_alv,
              ls_vari  type disvariant,
              ls_keyi  type slis_keyinfo_alv.
        data: l_index  type numc2,
              l_field  type fieldname.
        field-symbols: .
      Set key fields as common fields between header and detail
        loop at g_header_table->gt_fcat into ls_fcat
                                       where key = 'X'.
          l_index = l_index + 1.
        Create link
          concatenate 'HEADER' l_index into l_field.
          assign component l_field of structure ls_keyi to init_block_list.
            endif.
          endif.
        endif.
      Get default user variant
        call method g_header_table->get_default_variant
          changing
            out_variant = ls_vari.
        if g_block_mode is initial.
          call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
            exporting
              i_callback_program = g_header_table->g_repid
              is_layout          = g_header_table->gs_layo
              it_fieldcat        = lt_fcat
              it_sort            = lt_sort
              i_save             = 'U'
              is_variant         = ls_vari
              it_events          = g_header_table->gt_evnt
              i_tabname_header   = g_header_table->g_table
              i_tabname_item     = g_detail_table->g_table
              is_keyinfo         = ls_keyi
              is_print           = g_header_table->gs_prin
            tables
              t_outtab_header    =  0.
            raise display_error.
          endif.
        endif.
      endmethod.                    "output_hierarchy
      Init block list
      method init_block_list.
        data:  ls_evnt1 type slis_alv_event,
               ls_evnt2 type slis_alv_event.
      Events for whole list display
        concatenate 'F_' slis_ev_pf_status_set '_BLOCK'
               into ls_evnt1-form.
        concatenate 'F_' slis_ev_user_command '_BLOCK'
               into ls_evnt2-form.
      Initialization of block list
        call function 'REUSE_ALV_BLOCK_LIST_INIT'
          exporting
            i_callback_program       = me->g_repid
            i_callback_pf_status_set = ls_evnt1-form
            i_callback_user_command  = ls_evnt2-form.
      endmethod.                    "init_block_list
      End of block list
      method end_block_list.
        data: l_object type ref to lcl_table_display,
              ls_print type slis_print_alv.
        check not g_block_mode is initial.
        if in_print is supplied.
          ls_print = in_print.
        else.
          read table gt_table_obj into l_object index 1.
          ls_print = l_object->gs_prin.
        endif.
        call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
          exporting
            is_print      = ls_print
          exceptions
            program_error = 1
            others        = 2.
        if sy-subrc <> 0.
          raise display_error.
        endif.
        call method refresh_objects.
      endmethod.                    "end_block_list
      Refresh table of objects
      method refresh_objects.
        free: gt_table_obj.
      endmethod.
      Fill field catalog
      method fill_fieldcat.
        data: lt_abap   type rsfb_source.
        data: ls_defin  type ty_defin.
        data: lt_dfies  type table of dfies,
              ls_dfies  type dfies,
              ls_dd04v  type dd04v,
              ls_dd01v  type dd01v,
              l_flong   type dfies-lfieldname,
              l_dname   type dfies-domname.
        data: ls_fcat   type slis_fieldcat_alv,
              ls_fcat2  type slis_fieldcat_alv.
        data: l_index   type i,
              l_nbfld   type i.
        free: me->gt_defin.
      Process data definition
        call method get_definition
          exporting
            repid = repid
            struc = struc
          changing
            abap  = lt_abap.
      Process sub levels if required
        call method recursive_definition
          exporting
            repid = repid
          changing
            abap  = lt_abap.
        if me->gt_defin is initial.
          raise no_definition.
        endif.
        loop at me->gt_defin into ls_defin.
          clear: ls_fcat.
          move-corresponding ls_defin to ls_fcat.
        Retrieve info about this field
          free: ls_dfies, ls_dd04v, ls_dd01v, l_dname.
          l_flong = ls_fcat-ref_fieldname.
          set locale language 'E'.
          translate: ls_fcat-ref_tabname   to upper case,
                     ls_fcat-ref_fieldname to upper case,
                     l_flong               to upper case.
          if not ls_fcat-ref_tabname is initial.
          Try to get info about field in table
            call function 'DDIF_FIELDINFO_GET'
              exporting
                tabname        = ls_fcat-ref_tabname
                fieldname      = ls_fcat-ref_fieldname
                lfieldname     = l_flong
              importing
                dfies_wa       = ls_dfies
              exceptions
                not_found      = 1
                internal_error = 2
                others         = 3.
            if sy-subrc = 0.
              move-corresponding ls_dfies to ls_fcat.
              ls_fcat-fieldname = ls_defin-fieldname.
              move: ls_dfies-keyflag   to ls_fcat-key,
                    ls_dfies-scrtext_m to ls_fcat-seltext_l,
                    ls_dfies-domname   to l_dname.
            endif.
          else.
          Try to get info about structure
            ls_defin-ref_tabname = ls_defin-ref_fieldname.
            call function 'DDIF_FIELDINFO_GET'
              exporting
                tabname   = ls_defin-ref_tabname
              tables
                dfies_tab = lt_dfies
              exceptions
                others    = 0.
            if not lt_dfies is initial.
            Process fields of this structure
              loop at lt_dfies into ls_dfies.
                clear: ls_fcat.
                move-corresponding ls_dfies to ls_fcat.
                if ls_defin-fieldname ne 'INCLUDE'.
                  concatenate ls_defin-fieldname ls_fcat-fieldname
                         into ls_fcat-fieldname
                    separated by '-'.
                endif.
                move ls_dfies-keyflag to ls_fcat-key.
                move ls_dfies-scrtext_m to ls_fcat-seltext_l.
                ls_fcat-tabname = me->g_table.
                clear: ls_fcat-col_pos,
                       ls_fcat-offset.
                if ls_fcat-ref_tabname is initial.
                  ls_fcat-ddictxt = 'L'.
                endif.
              Display Yes/No fields as checkboxes
                if ls_dfies-domname = 'XFELD'.
                  ls_fcat-checkbox = 'X'.
                endif.
              Add field to field catalog
                append ls_fcat to fcat.
              endloop.
              continue.
            else.
            Try to get info about data element
              call function 'DDIF_DTEL_GET'
                exporting
                  name          = ls_fcat-ref_fieldname
                  langu         = sy-langu
                importing
                  dd04v_wa      = ls_dd04v
                exceptions
                  illegal_input = 1
                  others        = 2.
              if sy-subrc = 0.
                move-corresponding ls_dd04v to ls_fcat.
                move: ls_dd04v-scrtext_m to ls_fcat-seltext_l,
                      ls_dd04v-domname   to l_dname.
              else.
              Finally try to get info about domain
                call function 'DDIF_DOMA_GET'
                  exporting
                    name          = ls_fcat-ref_fieldname
                    langu         = sy-langu
                  importing
                    dd01v_wa      = ls_dd01v
                  exceptions
                    illegal_input = 1
                    others        = 2.
                if sy-subrc = 0.
                  move-corresponding ls_dd01v to ls_fcat.
                  move: ls_dd01v-ddtext  to ls_fcat-seltext_l,
                        ls_dd01v-domname to l_dname.
                endif.
              endif.
            endif.
          endif.
        Table name must be internal table containing data
          ls_fcat-tabname = g_table.
        No offset
          clear: ls_fcat-offset.
        Default text is stored in long text
          if ls_fcat-ref_tabname is initial.
            ls_fcat-ddictxt = 'L'.
          endif.
        Display Yes/No fields as checkboxes
          if l_dname = 'XFELD'.
            ls_fcat-checkbox = 'X'.
          endif.
        Add field to field catalog
          append ls_fcat to fcat.
        endloop.
      Positions
        loop at fcat into ls_fcat.
          ls_fcat-row_pos = 1.
          ls_fcat-col_pos = sy-tabix.
          modify fcat from ls_fcat transporting row_pos col_pos.
        endloop.
      Link between fields
        describe table fcat lines l_nbfld.
        loop at fcat into ls_fcat.
          if sy-tabix ne l_nbfld.
            l_index = sy-tabix + 1.
            read table fcat into ls_fcat2 index l_index.
            if sy-subrc = 0.
              if ls_fcat-datatype = 'CURR'.
              Currency unit
                if ls_fcat2-datatype = 'CUKY'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  modify fcat from ls_fcat.
                else.
                  loop at fcat into ls_fcat2
                               from l_index
                              where datatype = 'CUKY'.
                  First currency unit after field
                    ls_fcat-cfieldname = ls_fcat2-fieldname.
                    ls_fcat-ctabname   = ls_fcat2-tabname.
                    modify fcat from ls_fcat.
                    exit.
                  endloop.
                  if sy-subrc ne 0.
                  No currency unit after field, try before
                    read table fcat into ls_fcat2
                                with key datatype = 'CUKY'.
                    if sy-subrc = 0.
                      ls_fcat-cfieldname = ls_fcat2-fieldname.
                      ls_fcat-ctabname   = ls_fcat2-tabname.
                      modify fcat from ls_fcat.
                    else.
                    Default is EURO
                      ls_fcat-currency = 'EUR'.
                    endif.
                  endif.
                endif.
              endif.
              if ls_fcat-datatype = 'QUAN'.
              Quantity unit
                if ls_fcat2-datatype = 'UNIT'.
                  ls_fcat-cfieldname = ls_fcat2-fieldname.
                  ls_fcat-ctabname   = ls_fcat2-tabname.
                  modify fcat from ls_fcat.
                endif.
              endif.
            endif.
          endif.
        endloop.
      endmethod.                    "fill_fieldcat
      Get definition of type from code source
      method get_definition.
        data: l_strng type rssource,
              ls_abap type rssource,
              l_fdpos type i,
              l_first type i,
              l_lastr type i.
        data: lt_incl type table of repid,
              ls_incl type repid.
      Get program code
        read report repid into abap.
        check sy-subrc eq 0.
      Get first line of definition
        concatenate 'BEGIN OF' struc into l_strng
                                separated by space.
        loop at abap into ls_abap.
          if ls_abap cs l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            if ls_abap(1) = '*' or ls_abap(sy-fdpos) cs '"'.
              continue.
            endif.
            if ls_abap+l_fdpos(1) ca ',. "'.
              l_first = sy-tabix.
              exit.
            endif.
          endif.
        endloop.
        if l_first is initial.
        Table is defined in an include
          call function 'RS_GET_ALL_INCLUDES'
            exporting
              program    = repid
            tables
              includetab = lt_incl
            exceptions
              others     = 1.
          if sy-subrc = 0.
            loop at lt_incl into ls_incl.
            Try to find definition in this include
              read report ls_incl into abap.
              loop at abap into ls_abap.
                if ls_abap cs l_strng.
                  l_fdpos = strlen( l_strng ) + sy-fdpos.
                  if ls_abap(1) = '*' or ls_abap(sy-fdpos) cs '"'.
                    continue.
                  endif.
                  if ls_abap+l_fdpos(1) ca ',. "'.
                    l_first = sy-tabix.
                    exit.
                  endif.
                endif.
              endloop.
              if not l_first is initial.
                exit.
              endif.
            endloop.
          endif.
        endif.
      Get last line of definition
        concatenate 'END OF' struc into l_strng
                              separated by space.
        loop at abap into ls_abap.
          if ls_abap cs l_strng.
            l_fdpos = strlen( l_strng ) + sy-fdpos.
            if ls_abap(1) = '*' or ls_abap(sy-fdpos) cs '"'.
              continue.
            endif.
            if ls_abap+l_fdpos(1) ca ',. "'.
              l_lastr = sy-tabix - l_first.
              exit.
            endif.
          endif.
        endloop.
      Keep only relevant code lines
        if l_first le 0
        or l_lastr le 0.
          refresh abap.
        else.
          delete abap to l_first.
          delete abap from l_lastr.
        endif.
      endmethod.                    "get_definition
      Get definition of type recursively
      method recursive_definition.
        data: lt_token type table of stokex,
              ls_token type stokex,
              lt_state type table of sstmnt,
              ls_state type sstmnt.
        data: ls_defin type ty_defin,
              l_reffld type fieldname.
        data: lt_recu  type rsfb_source.
      Retrieve tokens
        scan abap-source abap
                  tokens into lt_token
              statements into lt_state.
        loop at lt_state into ls_state.
          clear: ls_defin.
        Field name
          read table lt_token into ls_token
                             index ls_state-from.
          ls_defin-fieldname = ls_token-str.
        Reference type
          read table lt_token into ls_token
                             index ls_state-to.
          l_reffld = ls_token-str.
        Check if this type is defined in program
          free: lt_recu.
          call method get_definition
            exporting
              repid = repid
              struc = l_reffld
            changing
              abap  = lt_recu.
          if lt_recu is initial.
            if not g_level is initial.
              concatenate g_level ls_defin-fieldname
                     into ls_defin-fieldname separated by '-'.
              condense ls_defin-fieldname.
            endif.
            if l_reffld cs '-'.
              split l_reffld at '-'
                           into ls_defin-ref_tabname
                                ls_defin-ref_fieldname.
              if ls_defin-ref_tabname = 'SY'.
                ls_defin-ref_tabname = 'SYST'.
              endif.
            else.
              ls_defin-ref_fieldname = ls_token-str.
            endif.
            append ls_defin to me->gt_defin.
          else.
          Process sub levels
            if me->g_level is initial.
              me->g_level = ls_defin-fieldname.
            else.
              concatenate me->g_level ls_defin-fieldname into me->g_level
                                                 separated by '-'.
            endif.
            call method recursive_definition
              exporting
                repid = repid
              changing
                abap  = lt_recu.
            if me->g_level cs '-'.
              shift me->g_level right up to '-'.
              shift me->g_level right.
              shift me->g_level left deleting leading space.
            else.
              clear: me->g_level.
            endif.
          endif.
        endloop.
      endmethod.                    "recursive_definition
      Get fieldcat
      method get_alv_fieldcat.
        out_fieldcat = me->gt_fcat.
      endmethod.                    "get_alv_fieldcat
      Set table name
      method set_table_name.
        data: l_fcat type slis_fieldcat_alv.
        loop at me->gt_fcat into l_fcat.
          l_fcat-tabname = in_tabname.
          modify me->gt_fcat from l_fcat.
        endloop.
        me->g_table = in_tabname.
      endmethod.                    "set_table_name
      Set title
      method set_alv_title.
        me->g_title = in_title.
      endmethod.                    "set_alv_title
      Set fieldcat
      method set_alv_fieldcat.
        me->gt_fcat = in_fieldcat.
      endmethod.                    "set_alv_fieldcat
      Set field invisible
      method set_alv_fieldnoout.
        data: l_field type fieldname,
              l_noout type c,
              l_tech  type c,
              ls_fcat type slis_fieldcat_alv.
        l_field = in_field.
        if in_noout is supplied.
          l_noout = in_noout.
        else.
          l_noout = 'X'.
        endif.
        if in_tech is supplied.
          l_tech = in_tech.
        endif.
        loop at me->gt_fcat into ls_fcat
                           where fieldname = l_field.
          ls_fcat-no_out = l_noout.
          ls_fcat-tech   = l_tech.
          modify gt_fcat from ls_fcat transporting no_out tech.
        endloop.
      endmethod.                    "set_alv_fieldnoout
      Set field editable
      method set_alv_fieldedit.
        data: l_field type fieldname,
              l_edit  type c,
              ls_fcat type slis_fieldcat_alv.
        l_field = in_field.
        if in_edit is supplied.
          l_edit = in_edit.
        else.
          l_edit = 'X'.
        endif.
        loop at me->gt_fcat into ls_fcat
                           where fieldname = l_field.
          ls_fcat-edit = l_edit.
          modify gt_fcat from ls_fcat transporting edit.
        endloop.
      endmethod.                    "set_alv_fieldedit
      Set field text
      method set_alv_fieldtext.
        data: l_field type fieldname,
              ls_fcat type slis_fieldcat_alv.
        l_field = in_field.
        loop at me->gt_fcat into ls_fcat
                           where fieldname = l_field.
          ls_fcat-seltext_m = in_ftext.
          ls_fcat-ddictxt = 'M'.
          modify gt_fcat from ls_fcat transporting seltext_m ddictxt.
        endloop.
      endmethod.                    "set_alv_fieldtext
      Set field sum
      method set_alv_fieldsum.
        data: l_field type fieldname,
              l_dosum type c,
              ls_fcat type slis_fieldcat_alv.
        l_field = in_field.
        if in_dosum is supplied.
          l_dosum = in_dosum.
        else.
          l_dosum = 'X'.
        endif.
        loop at me->gt_fcat into ls_fcat
                           where fieldname = l_field.
          ls_fcat-do_sum = l_dosum.
          modify gt_fcat from ls_fcat transporting do_sum.
        endloop.
      endmethod.                    "set_alv_fieldsum
      Set line break in field catalog
      method set_alv_linebreak.
        data: l_field type fieldname,
              ls_fcat type slis_fieldcat_alv,
              l_tabix type i.
        l_field = in_field.
        read table me->gt_fcat into ls_fcat
                           with key fieldname = l_field.
        if sy-subrc = 0.
          l_tabix = sy-tabix.
        else.
          exit.
        endif.
        loop at me->gt_fcat into ls_fcat
                            from l_tabix.
          ls_fcat-row_pos = ls_fcat-row_pos + 1.
          modify gt_fcat from ls_fcat transporting row_pos.
        endloop.
      endmethod.                    "set_alv_linebreak
      Set settings
      method set_alv_settings.
        call method map_structure
          exporting
            source = in_settings
          changing
            destin = me->gs_sett.
      endmethod.                    "set_alv_settings
      Set layout
      method set_alv_layout.
        call method map_structure
          exporting
            source = in_layout
          changing
            destin = me->gs_layo.
      endmethod.                    "set_alv_layout
      Set printing options
      method set_alv_print.
        call method map_structure
          exporting
            source = in_print
          changing
            destin = me->gs_prin.
      endmethod.                    "set_alv_print
      Set sortings
      method set_alv_sorting.
        data: l_desc   type alvdynp-sortdown,
              l_group  type alvdynp-grouplevel,
              l_subtot type alvdynp-subtotals.
        data: ls_sort  type slis_sortinfo_alv,
              l_index  type i.
        if in_desc is supplied.
          l_desc = in_desc.
        endif.
        if in_group is supplied.
          l_group = in_group.
        else.
          l_group = '*'.
        endif.
        if in_subtot is supplied.
          l_subtot = in_subtot.
        else.
          l_subtot = 'X'.
        endif.
        describe table me->gt_sort lines l_index.
        l_index = l_index + 1.
        ls_sort-spos = l_index.
        ls_sort-fieldname = in_field.
        ls_sort-tabname = me->g_table.
        if l_desc is initial.
          ls_sort-up = 'X'.
        else.
          ls_sort-down = 'X'.
        endif.
        ls_sort-group = l_group.
        ls_sort-subtot = l_subtot.
        append ls_sort to me->gt_sort.
      endmethod.                    "set_alv_sorting
      Set key fields
      method set_alv_keys.
        data: l_key   type c,
              ls_fcat type slis_fieldcat_alv.
        if in_key is supplied.
          l_key = in_key.
        else.
          l_key = 'X'.
        endif.
        loop at me->gt_fcat into ls_fcat from 1 to in_level.
          ls_fcat-key = l_key.
          modify gt_fcat from ls_fcat transporting key.
        endloop.
      endmethod.                    "set_alv_keys
      Add event
      method set_alv_event.
        data: ls_evnt type slis_alv_event.
        loop at gt_evnt into ls_evnt
                       where name = in_name.
          ls_evnt-form = in_form.
          modify gt_evnt from ls_evnt transporting fo

  • Problems with deploying application

    I started on trying to get the Pentaho Business Intelligence Server (latest stable release) deployed to Oracle WebLogic. The error I get in the WebLogic console right now is below. Within this weblogic console output is a reference to a problem within my application.xml file, the contents my application.xml file is also included further down in this posting.
    +<Dec 6, 2010 7:13:33 PM EST> <Error> <J2EE> <BEA-160197> <Unable to load descriptor+
    C:\Oracle\Middleware\wlserver_10.3\samples\domains \wl_server\autodeploy\pentaho.ear/META-INF/application.xml of module pentaho.ear. The error is weblogic.descriptor.DescriptorException: Unmarshaller failed at weblogic.descriptor.internal.MarshallerFactory$1.c reateDescriptor(MarshallerFactory.java:161)
    at weblogic.descriptor.BasicDescriptorManager.createD escriptor(BasicDescriptorManager.java:323)
    at weblogic.application.descriptor.AbstractDescriptor Loader2.getDescriptorBeanFromReader(AbstractDescri ptorLoader2.java:788)
    at weblogic.application.descriptor.AbstractDescriptor Loader2.createDescriptorBean(AbstractDescriptorLoa der2.java:409)
    at weblogic.application.descriptor.AbstractDescriptor Loader2.loadDescriptorBeanWithoutPlan(AbstractDesc riptorLoader2.java:759)
    at weblogic.application.descriptor.AbstractDescriptor Loader2.loadDescriptorBean(AbstractDescriptorLoade r2.java:768)
    at weblogic.application.ApplicationDescriptor.getAppl icationDescriptor(ApplicationDescriptor.java:301)
    at weblogic.application.internal.EarDeploymentFactory .findOrCreateComponentMBeans(EarDeploymentFactory. java:178)
    at weblogic.application.internal.MBeanFactoryImpl.fin dOrCreateComponentMBeans(MBeanFactoryImpl.java:48)
    at weblogic.application.internal.MBeanFactoryImpl.rec oncileMBeans(MBeanFactoryImpl.java:157)
    at weblogic.management.deploy.internal.MBeanConverter .reconcile81MBeans(MBeanConverter.java:295)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.compatibilityProcessor(RedeployOp eration.java:182)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.setupPrepare(AbstractOperation.ja va:295)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.doPrepare(RedeployOperation.java: 121)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.prepare(AbstractOperation.java:21 7)
    at weblogic.deploy.internal.targetserver.DeploymentMa nager.handleDeploymentPrepare(DeploymentManager.ja va:749)
    at weblogic.deploy.internal.targetserver.DeploymentMa nager.prepareDeploymentList(DeploymentManager.java :1216)
    at weblogic.deploy.internal.targetserver.DeploymentMa nager.handlePrepare(DeploymentManager.java:250)
    at weblogic.deploy.internal.targetserver.DeploymentSe rviceDispatcher.prepare(DeploymentServiceDispatche r.java:160)
    at weblogic.deploy.service.internal.targetserver.Depl oymentReceiverCallbackDeliverer.doPrepareCallback( DeploymentReceiverCallbackDeliverer.java:171)
    at weblogic.deploy.service.internal.targetserver.Depl oymentReceiverCallbackDeliverer.access$000(Deploym entReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.Depl oymentReceiverCallbackDeliverer$1.run(DeploymentRe ceiverCallbackDeliverer.java:47)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapte rImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread. java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java :173)
    Caused by: com.bea.xml.XmlException: weblogic.descriptor.BeanAlreadyExistsException: Bean already exists:
    +"weblogic.j2ee.descriptor.ModuleBeanImpl@edc8b 460(/Mod+
    +ules[weblogic.descriptor.internal.DescriptorBeanKey@ee8 d02ab])"+
    at com.bea.staxb.runtime.internal.util.ReflectionUtil s.invokeMethod(ReflectionUtils.java:54)
    at com.bea.staxb.runtime.internal.RuntimeBindingType$ BeanRuntimeProperty.setValue(RuntimeBindingType.ja va:539)
    at com.bea.staxb.runtime.internal.AttributeRuntimeBin dingType$QNameRuntimeProperty.fillCollection(Attri buteRuntimeBindingType.java:381)
    at com.bea.staxb.runtime.internal.MultiIntermediary.g etFinalValue(MultiIntermediary.java:52)
    at com.bea.staxb.runtime.internal.AttributeRuntimeBin dingType.getFinalObjectFromIntermediary(AttributeR untimeBindingType.java:140)
    at com.bea.staxb.runtime.internal.UnmarshalResult.unm arshalBindingType(UnmarshalResult.java:200)
    at com.bea.staxb.runtime.internal.UnmarshalResult.unm arshalDocument(UnmarshalResult.java:169)
    at com.bea.staxb.runtime.internal.UnmarshallerImpl.un marshal(UnmarshallerImpl.java:65)
    at weblogic.descriptor.internal.MarshallerFactory$1.c reateDescriptor(MarshallerFactory.java:150)
    +... 24 more+
    Caused by: weblogic.descriptor.BeanAlreadyExistsException: Bean already exists:
    +"weblogic.j2ee.descriptor.ModuleBeanImpl@edc8b 460(/Modules[weblogic.descriptor.internal.DescriptorBeanKey@ee8 d02ab])"+
    at weblogic.descriptor.internal.ReferenceManager.regi sterBean(ReferenceManager.java:227)
    at weblogic.j2ee.descriptor.ApplicationBeanImpl.setMo dules(ApplicationBeanImpl.java:427)
    at sun.reflect.GeneratedMethodAccessor74.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.staxb.runtime.internal.util.ReflectionUtil s.invokeMethod(ReflectionUtils.java:48)
    at com.bea.staxb.runtime.internal.RuntimeBindingType$ BeanRuntimeProperty.setValue(RuntimeBindingType.ja va:539)
    at com.bea.staxb.runtime.internal.AttributeRuntimeBin dingType$QNameRuntimeProperty.fillCollection(Attri buteRuntimeBindingType.java:382)
    +... 30 more.>+
    +<Dec 6, 2010 7:13:35 PM EST> <Error> <Deployer> <BEA-149265>+
    +<Failure occurred in the execution of deployment request with ID '1291680813688' for task '1'. Error is: 'weblogic.management.DeploymentException: '+
    weblogic.management.DeploymentException:
    at weblogic.management.deploy.internal.MBeanConverter .reconcile81MBeans(MBeanConverter.java:303)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.compatibilityProcessor(RedeployOp eration.java:180)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.setupPrepare(AbstractOperation.ja va:295)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.doPrepare(RedeployOperation.java: 121)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.prepare(AbstractOperation.java:21 7)
    Truncated. see log file for complete stacktrace
    Caused By: weblogic.descriptor.BeanAlreadyExistsException: Bean already exists:
    +"weblogic.j2ee.descriptor.ModuleBeanImpl@edc8b 460(/Modules[weblogic.descriptor.internal.DescriptorBeanKey@ee8 d02ab])"+
    at weblogic.descriptor.internal.ReferenceManager.regi sterBean(ReferenceManager.java:227)
    at weblogic.j2ee.descriptor.ApplicationBeanImpl.setMo dules(ApplicationBeanImpl.java:427)
    at sun.reflect.GeneratedMethodAccessor74.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    Truncated. see log file for complete stacktrace>
    +<Dec 6, 2010 7:13:35 PM EST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application '_appsdir_pentaho_ear'.>+
    +<Dec 6, 2010 7:13:35 PM EST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004 weblogic.management.DeploymentException:+
    at weblogic.management.deploy.internal.MBeanConverter .reconcile81MBeans(MBeanConverter.java:303)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.compatibilityProcessor(RedeployOp eration.java:180)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.setupPrepare(AbstractOperation.ja va:295)
    at weblogic.deploy.internal.targetserver.operations.R edeployOperation.doPrepare(RedeployOperation.java: 121)
    at weblogic.deploy.internal.targetserver.operations.A bstractOperation.prepare(AbstractOperation.java:21 7)
    Truncated. see log file for complete stacktrace
    Caused By: weblogic.descriptor.BeanAlreadyExistsException: Bean already exists:
    +"weblogic.j2ee.descriptor.ModuleBeanImpl@edc8b 460(/Modules[weblogic.descriptor.internal.DescriptorBeanKey@ee8 d02ab])"+
    at weblogic.descriptor.internal.ReferenceManager.regi sterBean(ReferenceManager.java:227)
    at weblogic.j2ee.descriptor.ApplicationBeanImpl.setMo dules(ApplicationBeanImpl.java:427)
    at sun.reflect.GeneratedMethodAccessor74.invoke(Unkno wn Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    Truncated. see log file for complete stacktrace>
    The application.xml file that the above code is referencing looks like this:
    +<?xml version='1.0' encoding='UTF-8'?>+
    +<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
    +<module>+
    +<web>+
    +<web-uri>pentaho-ears/jboss/portal/pentaho.war</web-uri>+
    +<context-root>pentaho</context-root>+
    +</web>+
    +</module>+
    +<module>+
    +<web>+
    +<web-uri>pentaho-portal-layout.war</web-uri>+
    +<context-root>pentaho-portal-layout</context-root>+
    +</web>+
    +</module>+
    +<module>+
    +<web>+
    +<web-uri>pentaho-style.war</web-uri>+
    +<context-root>pentaho-style</context-root>+
    +</web>+
    +</module>+
    +<module>+
    +<web>+
    +<web-uri>pentaho-wars/pentaho-portal-layout.war</web-uri>+
    +<context-root>pentaho-portal-layout</context-root>+
    +</web>+
    +</module>+
    +<module>+
    +<web>+
    +<web-uri>pentaho-wars/pentaho-style.war</web-uri>+
    +<context-root>pentaho-style</context-root>+
    +</web>+
    +</module>+
    +<module>+
    +<web>+
    +<web-uri>pentaho.war</web-uri>+
    +<context-root>pentaho</context-root>+
    +</web>+
    +</module>+
    +</application>+
    Any help is appreciated
    Edited by: Wes Gibbs on Dec 6, 2010 6:18 PM

    Thank you once again Jay.  That corrected my problem.  I actually put the libraries in autodeploy\pentaho.ear\lib directory and it seemed to correct it.  I have another problem that I am unsure how to fix.  It is defined below.  The file that these errors are referring to ("applicationContext-spring-security.xml") is also posted below.  Any ideas what might be causing this issue?
    ERROR Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterChainProxy' defined in file
         [C:\pentaho\server\biserver-ee\pentaho-solutions\system\applicationContext-spring-security.xml]: Invocation of init method failed; nested exception is      org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'authenticationProcessingFilter' defined
    in file [C:\pentaho\server\biserver-ee\pentaho-solutions\system\applicationCont
    ext-spring-security.xml]: Cannot resolve reference to bean 'authenticationManage
    r' while setting bean property 'authenticationManager'; nested exception is org.
    springframework.beans.factory.BeanCreationException:
    Error creating bean with na
    me 'authenticationManager' defined in file [C:\pentaho\server\biserver-ee\pentah
    o-solutions\system\applicationContext-spring-security.xml]: Cannot resolve refer
    ence to bean 'daoAuthenticationProvider' while setting bean property 'providers'
    with key [0]; nested exception is org.springframework.beans.factory.BeanCreatio
    nException:
    Error creating bean with name 'daoAuthenticationProvider' defined in
    file [C:\pentaho\server\biserver-ee\pentaho-solutions\system\applicationContext
    -spring-security-hibernate.xml]: Cannot resolve reference to bean 'userDetailsSe
    rvice' while setting bean property 'userDetailsService'; nested exception is org
    .springframework.beans.factory.BeanCreationException:
    Error creating bean with n
    ame 'userDetailsService' defined in file [C:\pentaho\server\biserver-ee\pentaho-
    solutions\system\applicationContext-spring-security-hibernate.xml]: Cannot resol
    ve reference to bean 'userRoleDao' while setting bean property 'userRoleDao'; ne
    sted exception is org.springframework.beans.factory.BeanCreationException:
    Error
    creating bean with name 'userRoleDao' defined in file [C:\pentaho\server\biserv
    er-ee\pentaho-solutions\system\applicationContext-spring-security-hibernate.xml]
    : Cannot resolve reference to bean 'sessionFactory' while setting bean property
    'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCrea
    tionException:
    Error creating bean with name 'sessionFactory' defined in file [C
    :\pentaho\server\biserver-ee\pentaho-solutions\system\applicationContext-spring-
    security-hibernate.xml]: Invocation of init method failed; nested exception is j
    ava.lang.NoClassDefFoundError: org/dom4j/DocumentException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1863)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3126)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1512)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
    at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
    at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
    at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
    at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
    at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
    at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
    at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
    at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
    at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
    at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    * End of Output for the weblogic error log, the following is the text from my applicationContext-spring-security.xml file: *
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springsource.org/dtd/spring-beans.dtd">
    <!--+
    | Application context containing FilterChainProxy.
    +-->
    <beans>
    <!-- ======================== FILTER CHAIN ======================= -->
         <!--
              if you wish to use channel security, add "channelProcessingFilter," in
              front of "httpSessionContextIntegrationFilter" in the list below
         -->
         <bean id="filterChainProxy" class="org.springframework.security.util.FilterChainProxy">
              <property name="filterInvocationDefinitionSource">
                   <value>
    <![CDATA[CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    PATTERN_TYPE_APACHE_ANT
    /**=securityContextHolderAwareRequestFilter,httpSessionContextIntegrationFilter,httpSessionReuseDetectionFilter,logoutFilter,authenticationProcessingFilter,basicProcessingFilter,requestParameterProcessingFilter,anonymousProcessingFilter,pentahoSecurityStartupFilter,exceptionTranslationFilter,filterInvocationInterceptor]]>
                   </value>
              </property>
         </bean>
    <!-- ======================== AUTHENTICATION ======================= -->
         <bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager">
              <property name="providers">
                   <list>
                        <ref bean="daoAuthenticationProvider" />
                        <ref local="anonymousAuthenticationProvider" />
                   </list>
              </property>
         </bean>
    <!-- Automatically receives AuthenticationEvent messages -->
         <bean id="loggerListener"
              class="org.springframework.security.event.authentication.LoggerListener" />
         <bean id="basicProcessingFilter"
              class="org.springframework.security.ui.basicauth.BasicProcessingFilter">
              <property name="authenticationManager">
                   <ref local="authenticationManager" />
              </property>
              <property name="authenticationEntryPoint">
                   <ref local="basicProcessingFilterEntryPoint" />
              </property>
         </bean>
         <bean id="basicProcessingFilterEntryPoint"
              class="org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint">
              <property name="realmName" value="Pentaho Realm" />
         </bean>
    <!-- custom Pentaho begin -->
         <bean id="requestParameterProcessingFilter"
              class="org.pentaho.platform.web.http.security.RequestParameterAuthenticationFilter">
              <property name="authenticationManager">
                   <ref local="authenticationManager" />
              </property>
              <property name="authenticationEntryPoint">
                   <ref local="requestParameterProcessingFilterEntryPoint" />
              </property>
         </bean>
         <bean id="requestParameterProcessingFilterEntryPoint"
              class="org.pentaho.platform.web.http.security.RequestParameterFilterEntryPoint" />
    <bean id="pentahoSecurityStartupFilter"
    class="org.pentaho.platform.web.http.security.SecurityStartupFilter">
    <property name="injectAnonymous" value="true" />
    </bean>
    <!-- custom Pentaho end -->
         <bean id="anonymousProcessingFilter"
              class="org.springframework.security.providers.anonymous.AnonymousProcessingFilter">
              <property name="key" value="foobar" />
              <property name="userAttribute" value="anonymousUser,Anonymous" />
         </bean>
         <bean id="anonymousAuthenticationProvider"
              class="org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider">
              <property name="key" value="foobar" />
         </bean>
         <bean id="httpSessionContextIntegrationFilter"
              class="org.springframework.security.context.HttpSessionContextIntegrationFilter" />
         <bean id="logoutFilter" class="org.springframework.security.ui.logout.LogoutFilter">
              <constructor-arg value="/index.jsp" />
    <!-- URL redirected to after logout -->
              <constructor-arg>
                   <list>
                        <bean class="org.pentaho.platform.web.http.security.PentahoLogoutHandler" />
                        <bean
                             class="org.springframework.security.ui.logout.SecurityContextLogoutHandler" />
                   </list>
              </constructor-arg>
              <property name="filterProcessesUrl" value="/Logout" />
         </bean>
         <bean id="securityContextHolderAwareRequestFilter"
              class="org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter" />
         <bean id="httpSessionReuseDetectionFilter"
              class="org.pentaho.platform.web.http.security.HttpSessionReuseDetectionFilter">
              <property name="filterProcessesUrl" value="/j_spring_security_check" />
              <property name="sessionReuseDetectedUrl" value="/Login?login_error=2" />
         </bean>
         <!--
              ===================== HTTP REQUEST SECURITY ====================
         -->
         <bean id="exceptionTranslationFilter"
              class="org.springframework.security.ui.ExceptionTranslationFilter">
              <property name="authenticationEntryPoint">
                   <ref local="authenticationProcessingFilterEntryPoint" />
              </property>
              <property name="accessDeniedHandler">
                   <bean class="org.springframework.security.ui.AccessDeniedHandlerImpl" />
              </property>
         </bean>
         <bean id="authenticationProcessingFilter"
              class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
              <property name="authenticationManager">
                   <ref local="authenticationManager" />
              </property>
              <property name="authenticationFailureUrl" value="/Login?login_error=1" />
              <property name="defaultTargetUrl" value="/Home" />
              <property name="filterProcessesUrl" value="/j_spring_security_check" />
              <property name="targetUrlResolver">
                   <bean id="targetUrlResolver" class="org.springframework.security.ui.TargetUrlResolverImpl">
                        <property name="justUseSavedRequestOnGet" value="true" />
                   </bean>
              </property>
         </bean>
         <bean id="authenticationProcessingFilterEntryPoint"
              class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
              <property name="loginFormUrl" value="/Login" />
              <property name="forceHttps" value="false" />
         </bean>
         <bean id="httpRequestAccessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
              <property name="allowIfAllAbstainDecisions" value="false" />
              <property name="decisionVoters">
                   <list>
                        <ref bean="roleVoter" />
                   </list>
              </property>
         </bean>
         <!--
              Note the order that entries are placed against the
              objectDefinitionSource is critical. The FilterSecurityInterceptor will
              work from the top of the list down to the FIRST pattern that matches
              the request URL. Accordingly, you should place MOST SPECIFIC (ie
              a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*)
              expressions last
         -->
         <bean id="filterInvocationInterceptor"
              class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
              <property name="authenticationManager">
                   <ref local="authenticationManager" />
              </property>
              <property name="accessDecisionManager">
                   <ref local="httpRequestAccessDecisionManager" />
              </property>
              <property name="objectDefinitionSource">
                   <value>
                        <!--
                             Note - the "=Nobody" below is saying that resource URLs with those
                             patterns not be available through a web call.
                        -->
    <![CDATA[
    CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
    \A/docs/.*\Z=Anonymous,Authenticated
    \A/mantlelogin/.*\Z=Anonymous,Authenticated
    \A/mantle/mantleloginservice/*\Z=Anonymous,Authenticated
    \A/mantle/.*\Z=Authenticated
    \A/welcome/.*\Z=Anonymous,Authenticated
    \A/public/.*\Z=Anonymous,Authenticated
    \A/login.*\Z=Anonymous,Authenticated
    \A/ping/alive.gif.*\Z=Anonymous,Authenticated
    \A/j_spring_security_check.*\Z=Anonymous,Authenticated
    \A/getimage.*\Z=Anonymous,Authenticated
    \A/getresource.*\Z=Anonymous,Authenticated
    \A/admin.*\Z=Admin
    \A/auditreport.*\Z=Admin
    \A/auditreportlist.*\Z=Admin
    \A/versioncontrol.*\Z=Admin
    \A/propertieseditor.*\Z=Admin
    \A/propertiespanel.*\Z=Admin
    \A/subscriptionadmin.*\Z=Admin
    \A/resetrepository.*\Z=Admin
    \A/viewaction.*solution.admin.*\Z=Admin
    \A/scheduleradmin.*\Z=Admin
    \A/publish.*\Z=Admin
    \A/logout.*\Z=Anonymous
    \A/solutionrepositoryservice.*component=delete.*solution=system.*\Z=Nobody
    \A/solutionrepositoryservice.*solution=system.*component=delete.*\Z=Nobody
    .*system.*pentaho.xml.*=Nobody
    .*system.*applicationcontext.*.xml.*=Nobody
    .*system.*pentahoobjects.spring.xml.*=Nobody
    .*system.*pentahosystemconfig.xml.*=Nobody
    .*system.*adminplugins.xml.*=Nobody
    .*system.*plugin.properties.*=Nobody
    .*system.*publisher_config.xml.*=Nobody
    .*system.*sessionstartupactions.xml.*=Nobody
    .*system.*systemlisteners.xml.*=Nobody
    .*system.*hibernate.*=Nobody
    .*system.*birt/.*=Nobody
    .*system.*dialects/.*=Nobody
    .*system.*google/.*=Nobody
    .*system.*jasperreports/.*=Nobody
    .*system.*jfree/.*=Nobody
    .*system.*kettle/.*=Nobody
    .*system.*logs/.*=Nobody
    .*system.*metadata/.*=Nobody
    .*system.*mondrian/.*=Nobody
    .*system.*olap/.*=Nobody
    .*system.*quartz/.*=Nobody
    .*system.*simple-jndi/.*=Nobody
    .*system.*smtp-email/.*=Nobody
    .*system.*ui/.*=Nobody
    .*system.*analysistemplate.tpl.*=Nobody
    .*system.*\.\./.*=Nobody
    \A/.*\Z=Authenticated
    ]]>
                   </value>
              </property>
         </bean>
    </beans>

  • I don�t understand those connection pools?

    Does anyone have a really clear example on how to set up a connection pool in my controler Servlet's init() method, and how I can access that pool, and pick up a connection from within my dbConnect Bean. If this is not a proper setup, please comment. Because I'm lost.
    I've been struggling for a while with setting up a pool, and used the com.javaexchange.dbConnectionBroker package. It is possible to make my dbConnect bean a servlet, and make it the supercalss of my controler, so the controler inherits the global pool. But can I call methods in the dbConnect servlet from my controler servlet?
    I just want to have some input before I throw the entire thing around again.

    Create a servlet that will instantiate dbConnectionbroker or whatever connection pool. Initalize list of connection thru that and load it. And then pre-load this servlet in servlet container.
    To access or get a connection from pool, get pre loaded servlet from conatainer and then get instance of connection pool manager and then get the connection from it.
    I hope this works for you....
    chao

  • Using File class

    For an assignment I have I was told to make a constructor that inputs a File object, I think i properly created this object in my main program but when I put
    public classname(File file1) for my constructor it gives me the error "File cannot be resolved to a type".
    my questions are:
    -how do i properly use a File object as a parameter for a constructor?
    -how do i do test for the end of a file with a File object?

    you didn't fully name the File classhmm i dont follow i guess.If you didn't use an import statement, you'd have to say java.io.File when you used it in the constructor argument list.
    Did you use an import statement?do you mean import java.io.File;? i do
    have that if thats what your asking.Yes that's what I meant.
    You're doing something else wrong, then, but I can't tell what since it'll be in code that you didn't post.
    Do you have any other classes called "File"?
    You don't. File doesn't have any concept of that. Itdoesn't really make sense. It only makes sense with
    things that step through a file's contents, like a
    FileInputStream.
    ok well my example in my book shows a program
    stepping through a File using a scanner and
    .nextLine(), if this is how i read the file what
    would be returned when it came to the end? does throw
    IOException have something to do with this?You would use "hasNextLine" and if it returns false, you stop. You don't specifically check for the end of file in this case. Use the various "hasNext" methods depending on what you're trying to do.
    Apparently Scanner doesn't throw IOException in nextLine(), and anyway using exceptions to find the end of input is the wrong way to go about this.

  • ItemEditor validation question

    I have an app with a datagrid populate by items dragged into
    it. I have an object method that adds up the quantities of the
    dropped objects and displays an error in they exceed the amount
    defined in the object's properties. Works fine.
    However, now I need to include data checking on a PER ITEM
    level; that is, the XML entries for each grid item has its own min
    and max qty, not just the list as a total. Can anyone recommend a
    strategy for updating my old code to accomodate this?
    A typical entry is <item ln1="Bacon" minQy="1/2" maxQy="1"
    qty="1" units="lb." sn="bacon" />
    I create each list item with: private var _list2 : List = new
    List(0,1,.25,.25,"lbs","Meats") and then check the list with
    _errQty = _list2.checkTotal(app._chosen2);
    The list object:
    quote:
    public class List extends Object {
    import mx.collections.*;
    include "DialogStrings.as";
    // CONSTRUCTOR
    function
    List(_minC:Number,_maxC:Number,_minQ:Number,_maxQ:Number,_un:String,_ingName:String){
    _minChoices = _minC;
    _maxChoices = _maxC;
    _minQty = _minQ;
    _maxQty = _maxQ;
    _units = _un;
    _shortName = _ingName;
    // PRIVATE VARIABLES
    private var _minChoices : Number;
    private var _maxChoices : Number;
    private var _maxQty : Number;
    private var _minQty : Number;
    private var _units : String;
    public var _shortName : String;
    // checks the total quantities, returns error string
    public function checkTotal(_arr:ArrayCollection) : String {
    var _errType:String = "";
    var _n:Number = getTotal(_arr)
    if (_n > _maxQty) {
    _errType = "over";
    else if (_n < _minQty){
    _errType = "under";
    } else {
    _errType = "";
    switch (_errType){
    case "over":
    return getMaxQtyError();
    break;
    case "under":
    return getMinQtyError();
    break;
    case "":
    return "";
    trace("Quantity OK");
    break;
    default:
    return "";
    trace("no matching error condition");
    break;
    // adds up the quantities, returns sum
    private function getTotal(_arr:ArrayCollection) : Number {
    var _sum : Number = 0;
    var _length : Number = _arr.length;
    for(var i:Number=0; i<_length; i++) {
    var _item : Object = _arr.getItemAt( i );
    var _value : Number = _item["@qty"];
    _sum += _value;
    return _sum;

    Thanks I'll just have to wait till I get the email back.
    I had a look now and it appears Apple have added Macbook Air to the list. I was confused for quite some time as to what to choose when Air wasnt on the drop down menu.
    As long as the serial number dictates the vaildity of my request rather than the model then I'm happy.
    thanks

  • Search method problem

    Hi again,
    I have problems about my search method at the below. It always create ArrayIndexOutOfBounds Exception. According to this error, the index(38) equals to the size of my arraylist. So how can I fix it ??
    import java.util.*;
    * ...Listdescription...
    * @author  ...yourname...
    * @version 1.00, 2006/05/19
    public class List
         // properties
         ArrayList store;
         int index = 0;
         // constructors
         public List(){
              store = new ArrayList();
         // methods
         public void add(Object e,int node){
              store.add(node, e);
         public void addHead(Object e){
              store.add(0, e);
         public void addTail(Object e){
              store.add(e);
         // recursive method     
         public void toString(int a){
              if(store.size() == a )
                   System.out.println( "");
              else{
                   System.out.println(store.get(a));
                   toString(a + 1);
         // recursive method
         public int search(Object e){
    //          if(index == store.size())
    //               return -1;
              if(e == store.get(index)){
                   return store.indexOf(e);
              else{
                   index++;               
                   return search(e);               
         public static void main( String[] args)
                 List myList = new List();
                 for(int a = 0; a < 35; a++ )
                      myList.add(a,new Integer(a));
                 myList.add(35,new Integer(35));
                 myList.addHead(new Integer(36));
                 myList.addTail(new Integer(39));
                 myList.toString(0);
                 System.out.println(myList.search(new Integer(3)));
    } // end of class List

    Do you think that the following can run for all object types ?
         public int search(Object e){
              if(index == store.size())
                   return -1;
              if(e.equals(store.get(index))){
                   return store.indexOf(e);
              else{
                   index++;               
                   return search(e);               
         }

  • Remote File accessing from java WebNFS

    Hi
    I am using java WebNFS package provided by sun to access the remote file system from java class. A class called com.sun.xfile.XFile does this functionality and it is almost similar to java.io.File. My issue is I am trying to lookup a Windows NT File Server through the XFile constructor and list out all the files in a particular directory. When I run the sample class from a Windows Machine it is working fine. But when I run the same class from a Linux machine, the XFile class couldnt resolve the path. Do those Linux server and the Windows NT File server should have been mounted ? Suggestions are welcome. Thx in advance.

    viswa07 wrote:
    Ya Darryl.Thanks for ur reply.Tell me now how to do that action..????What Darryl is pointing out is that no one is going to reply to you because you have a history of not replying to questions - think about it - if someone asked you a question and you asked them a question to help you understand what they were asking and they walked away, and then did that again - would you keep trying to help?

  • CS-Man: Pac-Man (the game, not the package manager!) clone in Java/SWT

    Wasn't sure whether this would go here or Off Topic, but w/e.
    I'm working on a Pac-Man clone for my AP Computer Science class, me and a friend. We're using Java and the SWT toolkit to write a suckish Pac-Man clone. We've been working on it for 2-3 weeks now, and have a few more weeks to go. Keep in mind, this is AP Comp Sci -- not very advanced, though are project is a bit above and beyond We're just beginners, although we're both pretty certainly heading into programming as careers.
    You can check out the project, code, etc. at http://sourceforge.net/projects/cs-man . Bug reports and feature requests are very much welcome (not so much the latter actually, we have plans for more features than we'll ever get done already), but actual code is not -- it's BSD-licensed, but we need to do the project ourselves
    The current code doesn't do much at all, but it's close to working player movement. There are some obvious gaffes, but it's 2am and I just wanted to commit the code and work more tomorrow, so those should be fixed soon. The structure resembles to a large degree the GridWorld case study.
    The app works fine on Arch with GTK+ and on Windoze, and should on OS X as well (try SWT 3.5 development). Check out the code, add a user library called SWT with your SWT JAR and possibly source (Arch has these stored in /usr/share/eclipse/plugins/ or something like that), and try.
    And yes, the images and such are (obviously) just for testing. They look like crap, and the psychedelic Pac-Man pics we have aren't even transparent.
    Anyways, I'm off to bed.

    I thought I could have a looksie, since I aspire to be a teaching assistant in an introductory java course this fall. Java is not really my forte, though - i don't know many API's, just enough for the university courses. I've never used SWT.
    So, after fiddling a bit to get it working (I put SWT in my classpath, copied the image directory into src/ and started the app from there - could probably have buildt a jar or something too, but there was no makefile), here are some comments:
    I'm not saying all suggestions I make are better, I'd just like to know your reasoning. Some of them are just better, though
    1. Include a makefile/ant-makefile/cmake-file/scons-file/something. And a readme.
    2. GUI::map - why shorts? Why not bytes?
    3. Keeping references to all images in all classes makes for a lot of bookkeeping, and horrible constructor argument lists.  I'd create a helper class that serves up images (something like an ImageCollection -  images.getImage(ImageCollection::DOT)). Bonus: Themable application! Just implement a simple config file for the images at loading time
    This funcitonality could also be contained in MobMaze, as asking the Maze how it looks seems reasonable enough, and it seems most classes already keep a reference to it.
    Now, the next step is to decouple as much image handling as possible from the mObject derived classes. I'd make mObject hold a class variable that refers to the constant (or enum value) of the corresponding image - now MobMaze can use that value, and the mObject classes never have to touch a Image. Of course, the chomping logic for Player (and some state logic for having the trolls turn blue) must be implemented in overridden methods.
    4. Using shorts everywhere is not likely to speed up your code on 32 bit machines.
    5. In 'special' constructors, like Location::Location(int,int) - don't duplicate functionality from the general main worker constructor (Location::Location(int,int,int)). Call the main constructor with the default argument, instead. Keep the DRY principle in mind
    But good work! This is a fair bit more ambitious than I was in my programs for class.
    Anyway, I hope I made some sense. I'll see if I feel like having a more in-depth look.

Maybe you are looking for