Using Lists in a JSP through usebean

Hi,
Needed a small help.
I have a JSP where in i have to read a List and retrieve the Objects(Map objects) and get the values and display it in JSP.
I would like to use the <usebean> attribute to avoid scriptlets.
Please guide me through this.
Any help is appreciated.
Thanks in advance.

Two solutions are there. Either you have to use JSTL. Perfect example for your query is here [http://www.java2s.com/Tutorial/Java/0380__JSTL/UseForEachtoLoopThroughArrayList.htm|http://www.java2s.com/Tutorial/Java/0380__JSTL/UseForEachtoLoopThroughArrayList.htm]
OR write your own custom tag library.

Similar Messages

  • How to use List String in JSP page?

    Hello All,
    I am having problem using List<String> in my JSP page. Below is my JSP code.
    <%@ page import="java.util.*, java.io.*"%>
    <html>
    <body>
    <h1 align="center">Beer Recommendations JSP</h1>
    <p>
    <%
    List<String> beerBrands = (List<String>)request.getAttribute("styles");
    Iterator<String> it = beerBrands.iterator();
    while(it.hasNext()){
         out.print("<br>try: " + it.next());
    %>
    </body>
    </html>
    When I compile the above JSP code in Eclipse 3.4 (using JBoss 4.2 as my Application Server), I get the following Warning.
    Type safety: Unchecked cast from Enumeration to Enumeration<String>
    If I add the "@SuppressWarnings("unchecked")" to the code, Eclipse does not give any Error during compilation. But, at runtime, I get the following Error.
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 10 in the jsp file: /BeerAdvice.jsp
    Syntax error, annotations are only available if source level is 5.0
    7: <p>
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
    The type List is not generic; it cannot be parameterized with arguments <String>
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    14:      out.print("<br>try: " + it.next());
    An error occurred at line: 11 in the jsp file: /BeerAdvice.jsp
    Syntax error, parameterized types are only available if source level is 5.0
    8:
    9: <%
    10: @SuppressWarnings("unchecked")
    11: List<String> beerBrands = (List<String>)request.getAttribute("styles");
    12: Iterator<String> it = beerBrands.iterator();
    13: while(it.hasNext()){
    14:      out.print("<br>try: " + it.next());
    Any help is very much appreciated.
    Thank you for your help.
    Thanks,
    Chubha

    Hi anotherAikman,
    Thank you for your help. I currently have the following version of the Java.
    {color:#800000}java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
    {color:#000000}{color:#000000}Does it mean I have Java SE Version 6 Update 17 and you are suggesting me to download the Java EE Version 6?{color} If this is correct, can you please let me know what difference does it make?
    I am now going to install the Java EE 6 and try this out.
    Thank you for your help.{color}
    {color:#000000}Thanks,
    Chubha{color}
    {color}

  • Using variables in a jsp:useBean tag

    I was wondeing if it is possible in any way to use variables in a jsp:useBean tag. Here is an example of what I am trying to do.
    <%
    String beanType = request.getParameter( "bean" );
    if( beanType.equals( "Bean1" ) ) {
    beanClass = "com.myCompany.Bean1";
    } else {
    beanClass = "com.myCompany.Bean2";
    %>
    <jsp:useBean name="<%= beanType %>" class="<%= beanClass %>"/>
    I also tried using this approach
    <%
    if( beanType.equals( "Bean1" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean1"/>
    <%
    } else if( beanType.equals( "Bean2" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean2"/>
    <%
    %>
    Neither approach seems to work. Is there any way around this problem?
    Thanks,
    Marcus.

    Hi,
    check:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=398998&tstart=75&trange=15

  • How to use  SSL Technology in JSP.

    Can anybody Tell me that How to use SSL Technology in JSP ?
    I am using Apache Tomcat 5.0.28 Server.
    How to configure the Tomcat server so that it will access any web application supported by Tomcat via SSL ?
    Thank you very much in advance.

    The JSP does not need to know that the request is coming over SSL. If the application must be over SSL, but the server also allows non-SSL communication, then, like I said, you need to build in a Filter that will check if the incoming request is an https or http request and redirect to the https url if the request was http. And you can do that using the method listed in the previous post. As far as setting up the SSL certificate for Tomcat to use, refer to the Tomcat Documentation that comes with the server. Other than those two things, you don't need to know anything else about SSL inorder to run an SSL application through a Tomcat server (or any other enterprise server either, for that matter), but do an internet search for SSL and maybe one or two other keywords that apply to your situation and you should find plenty that will help.

  • How to call the Jsp through BPM Obejct

    Hi,
    I have gone through the some topic, how to call the Jsp through BPM Object.
    I have followed step below,
    1. I have create the sample jsp page
    2. Import into BPM studio under webroot\custom Jsp
    3. Created the screenflow and added the "Interactive Component call" object
    4. Right Click the Object and selected Maintask and Implementation type as "BPM Object Interactive Call"
    5. Selected the use JSP presentation object option and when i click ok its showing "BPM instance object must be selected"
    But when i select the Instance Variable tab, its not showing anything.
    Can any one help me how to call the Jsp in screenflow with step by step procedure, that would be very greate help for me.
    Regards,
    Anandh P

    Hi,
    You are running a jsp report through rwservlet. In this case paper layout will be displayed. You have to deploy your jsp as web report to get the web layout. Please refer to the doc below, which describes how to deploy the web report.
    http://download-uk.oracle.com/docs/html/B10314_01/pbr_run.htm#1011901
    To run the jsp report, URL may look like
    http://www.wwt.com/reports/<jsp name>?<parameter list>
    Hope this helps
    Vinayak

  • How to use vc++ com in jsp

    i have a com component in vc++ .its functions i want to use it in jsp through javabeans?????????????????/

    dont lose heart

  • Oepe-12.1.2.1-kepler how to use ADF Templates in JSP page

    Hi all,
        I use oepe 12.1.2.1 kepler 4.3 and creating JSP page but I can't see any ADF Rich Faces Page in JSP Templates Page of Preferences Dialog. How to use ADF Templates in JSP page?
    Thanks,
    Thomas

    Select the JSP Templates link. Is the ADF Rich Faces Page template listed? Refer Creating the Login Page/4.
    Introduction to the Oracle Enterprise Pack for Eclipse (OEPE) IDE

  • Using a JavaBean in JSP

    Hello,
    I am very new at this, and I am doing a very simple tutorial to use a JavaBean in JSP. I have followed all the procedures from my tutorial, and I get the following error:
    org.apache.jasper.JasperException: Can't find a method to write property 'make' of type 'java.lang.String' in a bean of type 'com.wrox.cars.CarBean'
    I have the bean:
    package com.wrox.cars;
    import java.io.Serializable;
    public class CarBean implements Serializable {
    private String make = "Ford";
    public CarBean(){
    public String getMake(){
    return make;
    public void SetMake(String make)
    this.make = make;
    and the JSP:
    <jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />
    I have a <jsp:getProperty name="myCar" property="make" /><br>
    <jsp:setProperty name="myCar" property="make" value="Ferrari" />
    Now I have a <jsp:getProperty name="myCar" property="make" /><br>
    The only thing I am missing is this step, where I have been looking for these JAR files and can't find them
    I have downloaded many JSTL libraries, and still can't find them/
    - dom.jar
    - jaxp-api.jar
    - jdbc2_0-stdext.jar
    - sax.jar
    - xalan.jar
    - xercesImpl.jar
    I really appreciate any help.

    Thanks a lot.
    Although I should know that, it seems that the error was in the tutorial.
    Thanks again,

  • Problem in Using Java Bean in JSP

    Hi,
    I have a bean called BankAccount.....I tried to use it in a jsp file called Usebean.jsp like this <jsp:useBean id="BA" class="BankAccount" scope="application" /> I tried in both tomcat and j2ee1.3 server... but when i run the jsp file i get an error saying..... Class.org.apache.jsp.BankAccount not found...... But i have put the class file properly inse classes folder.....
    Can anyone help me soon..... i am new to JSP........
    Thanks,
    Akshatha

    Well u need to have your class in a package
    like mypackage.BankAccount
    and put your class in classes/mypackage
    <jsp:useBean id="BA" class="mypackage.BankAccount" scope="application" />

  • Bug using list and treeset

    I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:
    package treeset;
    import java.util.Comparator;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.TreeSet;
    import java.io.Serializable;
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class TreeSetExample
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The TreeSetExample demonstreates a odity in the sorting of list using a treeset
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class TreeSetExample extends Object {
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * Constructs a TreeSetExample object
    public TreeSetExample() {
    } // end constructor
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * getDatea
    public List<SimpleVO> getData() {
       List<SimpleVO> returnList = new LinkedList<SimpleVO>();
       SimpleVO simpleVO = null;
       for (int i = 0;i < 5;i++) {
          returnList.add(new SimpleVO());
       } // end for
       return(returnList);
    } // end getData
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * runTest - Test the insert sorting of a tree set with a list of data
    * @param loopCount number of time to load data into the saveset
    public void runTest(int loopCount) {
       List<SimpleVO>    simpleList   = getData();
       SimpleVO          simpleVO     = null;
       TreeSet<SimpleVO> saveSet      = new TreeSet<SimpleVO>(new simpleComparator());
       SimpleVO          tempSimpleVO = null;
       Iterator<SimpleVO> iterator      = null;
       Iterator<SimpleVO> printIterator = null;
       int id = 0;
       for (int i = 0; i < loopCount;i++) {
          iterator = simpleList.iterator();
       // for each of the user's zip codes find the distance to the RSL
       while (iterator.hasNext()) {
          simpleVO = iterator.next();
          id ++;
          simpleVO.setName("" + id);
          saveSet.add(simpleVO);
       } // end while
       // print saveset at the end of each load
       System.out.println("list count after loop [" + (i + 1) + "] number of elements = [" + saveSet.size() + "] contents:");
       printIterator = saveSet.iterator();
       while(printIterator.hasNext()) {
          tempSimpleVO = printIterator.next();
          System.out.println(" save simpleVO name = [" + tempSimpleVO.getName() + "]");
       } // end while
       } // end For
    } // end runTest
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // start main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    * IbotMailParser main thread
    * @param arg standard main input string array.
    public static void main(String[] arg) {
       System.out.println("Main - Started");
       try {
          System.out.println("*************** starting test 1 *********************");
          TreeSetExample treeSetExample = new TreeSetExample();
          treeSetExample.runTest(1);
          System.out.println("\n");
          System.out.println("\n");
          System.out.println("*************** starting test 2 *********************");
          treeSetExample.runTest(2);
       } // end try
       catch (Exception any) {
          System.out.println("Exception [" + any.getMessage() + "]");
       } // end catch
       System.out.println("Main - we gone bye-bye...!");
    } // end main
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The SimpleVO is a value object pattern used for this example
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class SimpleVO extends Object {
        * Default user name for Oracle connection.
       private String name = "";
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Returns the name value associated with this attribute
        * @return String - the Name parameter
       public String getName() {
          return(name);
       } // end getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start setName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Sets the name value for this attribute
        * @param newName the Name to be set
       public void setName(String newName) {
          if (newName != null) {
             name = newName.trim();
          } // end if
       } // end setName
    } // end SimpleVO
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    // Class simpleComparator
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    * The SimpleComparator is a comparator object used for sorting simple value objects
    * @version 1.0, 04/06/2011
    * @author  Douglas Nelson
    * @author  copyright Oracle 2011
    * @author  Unauthorized use, duplication or modification is strictly prohibited.
    public class simpleComparator implements Comparator<SimpleVO>, Serializable {
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
       // start getName
       //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        * Returns the name value associated with this attribute
        * @return String - the Name parameter
       public int compare(SimpleVO simpleVO_1, SimpleVO simpleVO_2) {
          return(1);
       } // end compare
    } // end SimpleComparator
    } // end class TreeSetExample
    output :
    c:\treeset>java treeset.TreeSetExample
    Main - Started
    *************** starting test 1 *********************
    list count after loop [1] number of elements = [5] contents:
    save simpleVO name = [1]
    save simpleVO name = [2]
    save simpleVO name = [3]
    save simpleVO name = [4]
    save simpleVO name = [5]
    *************** starting test 2 *********************
    list count after loop [1] number of elements = [5] contents:
    save simpleVO name = [1]
    save simpleVO name = [2]
    save simpleVO name = [3]
    save simpleVO name = [4]
    save simpleVO name = [5]
    list count after loop [2] number of elements = [10] contents:
    save simpleVO name = [6]
    save simpleVO name = [7]
    save simpleVO name = [8]
    save simpleVO name = [9]
    save simpleVO name = [10]
    save simpleVO name = [6]
    save simpleVO name = [7]
    save simpleVO name = [8]
    save simpleVO name = [9]
    save simpleVO name = [10]
    Main - we gone bye-bye...!
    Edited by: EJP on 7/04/2011 10:44: added code tags. Please use them.

    user12607386 wrote:
    I have a real world problem where I get a list of retail store location and get the distance from group of starting locations and find the 10 closest location for each starting locations. I get returned from getdata a list of stores loop through each store and calculate the distance and put them in a treeset for sorting. Problem is when the second set of data is added to the treeset the original set is replace with a duplicate set of the second set. a very simple test case for this is follows:Well, first off, when you post code, please put it in '' tags; but the basic problem is your[code]simpleVO.setName("" + id);[/code]line. A name should normally be *final*, so you shouldn't be able to set it at all.
    When you add the second set of 5 to your Set, you're simply changing the name of the first 5 you just added, but since your Comparator doesn't actually do anything useful, it allows the second 5 to be added, which, of course, then show up as duplicates.
    My advice: +THINK+ about what you want to do; don't just sit down and code. If need be, get out a pencil and paper and write out in English the steps you need.
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using BI Bean in JSP

    Hi,
    Can anyone please provider some pointers on using BIBeans in a JSP page. There are few options in my knowledge.
    1)Using BI-Beans API for writing our own JSP tags.
    2)In Jdev(10g) there seems to be some support for Graphs through ADF.
    3)JSP and UIX tags provided BI-Graph beans.
    thanks
    Rahul

    U may be used the code similar to following :
    Context context = new InitialContext.();
    Object obj = (Object)context.lookup("Your JNDI name");
    YourHome home = (YourHome)obj.portableRemoteObject.narrow(obj,
    YourHome.class);
    YourRemote remote = home.create();
    System.out.println("your Business methods : "+remote.businessMethod1());
    Put this code or whatever code used in ur console client in JSP and invoke the businessMethods using remote object.
    I worked with BEAWeblogic 5.1, I think similar case may be there with BEA Weblogic7 also.
    First, make a jar file with ome.Remote and Bean by using the deploymenttool, then compile with ejb compiler, the new Jar is the complete deployable file. Take this file and register in weblogic.properties file that is specify the path of the Jar file in the weblogic.properties file. and put the JSP in public-html directory and start the server. if the bean is deployed successfully, open JSP file in a browser then it will work.... if the bean is not deployed you won't get any result.
    I can say, just placing the initialContext part of code on the JSP and running the JSP. I think, this may helps u...
    Ramana

  • Using JSTL variables in JSP or Javascript. Possible ?

    Hi All,
    Is it possible to share or use the variables which are declared are used by JSTL in JSP expression or scriplet code and in Java Script.
    Example:
    This Works:
    <fmt:set var="test" value="JSTL" />
    <fmt:out value="${test}" />
    But, this gives error:
    <% out.println(test) %>
    And passing the value of variable 'test' to Java Script code also gives error.
    How to use JSTL variables in JSP and in Javascript ?
    Yours,
    Sankar.B

    By default, JSTL variables are kept in servlet
    attributes. Default is to store it in the page
    context. You can make it request/session/application
    scope as required by an attribute of the set tag.Hi there,
    Can anyone advise how to access JSP variables in JSTL?
    Can it be done as the same method through request/session/application scope?
    Thnks...

  • Inserting items into List on a JSP

    I want to insert new items into a multiple select list from database
    on selecting an item from an existing list in a JSP.
    I am not sure how to do this.
    thanks

    This is basically performing partial page rendering. There is no way for HTML or JavaScript executing in a user's browser to communicate directly with Java or your database. You'll either have to "preseed" the values from the database into the HTML page using JavaScript, and then change the select list w/ JavaScript based on what the user selects (this is how it's usually done.)
    Or, you could do something like using a hidden IFrame as a data conduit to your JSP which sends JavaScript back to the browser and updates the select list with the new values. A little more tricky, and doesn't work w/ all browsers, but it would work better if the data in question can be arbitrarily large.
    Hope that helps.

  • Logo using  List ALV list dispaly

    Hi,
    I am using FM:REUSE_ALV_COMMENTARY_WRITE to print logo in ALv header with list display using REUSE_ALV_LIST_DISPLAY.
    Header is being displayed except logo.Below is the code.
    Please let me know if anything to be done additionally to get the logo ,if naybody has displayed logo using list display i mean above FMs.
    FORM TOP_OF_PAGE.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = ''.
      append x_heading to t_heading.
    Program name
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Program: '.
      x_heading-info = sy-repid.
      append x_heading to t_heading.
    User who is running the report
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'User: '.
      x_heading-info = sy-uname.
      append x_heading to t_heading.
    Date of execution
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'Date: '.
      write sy-datum to x_heading-info.
      append x_heading to t_heading.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
           I_LOGO                   = 'ENJOYSAP_LOGO'
           IT_LIST_COMMENTARY       = t_heading
      I_END_OF_LIST_GRID       =
       I_ALV_FORM               = 'X'.
    ENDFORM.

    Hi,
    Kindly go through this below sample program:
    *+
    REPORT  YKC_ALV_OOPS_LOGO_DISPALY.
    tables: MARA.
    TYPE-POOLS cndp.
    data: begin of it_tab occurs 0,
          matnr like mara-matnr,
          ersda like mara-ersda,  "creation date
          ernam like mara-ernam,  "person created
          pstat like mara-pstat,  "maint stat
          lvorm like mara-lvorm,  "flg for deletion
          mtart like mara-mtart,  "mat type
          meins like mara-meins,  "uom
          end of it_tab.
    data: wa_it_tab like line of it_tab.  "making work area
    data: i_modified TYPE STANDARD TABLE OF mara,"For getting modified rows
          w_modified TYPE mara.
    CLASS lcl_events_d0100 DEFINITION DEFERRED.
    DATA: event_receiver1  TYPE REF TO lcl_events_d0100,
          i_selected_rows TYPE lvc_t_row,                "Selected Rows
          w_selected_rows TYPE lvc_s_row.
    *----declaration for logo display custom container
    DATA  url(132).
    custom container
    DATA pic_container TYPE REF TO cl_gui_custom_container.
    picture Control.
    DATA picture TYPE REF TO cl_gui_picture.
    Definition of Control Framework
    CLASS cl_gui_cfw DEFINITION LOAD.
          CLASS lcl_events_d0100 DEFINITION
    CLASS lcl_events_d0100 DEFINITION.
      PUBLIC SECTION.
       METHODS:
    *double_click FOR EVENT double_click
                            OF cl_gui_alv_grid
                            IMPORTING e_row
                                      e_column.
        METHODS
            handle_hotspot_click
            FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
                 e_row_id
                 e_column_id
                 es_row_no
                 sender.
    *---code addition for ALV pushbuttons
    *--for placing buttons
        METHODS handle_toolbar_set
            FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING
                  e_object
                  e_interactive.
    *---user command on clicking a button
        METHODS handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING
                 e_ucomm.
    ENDCLASS.                    "lcl_events_d0100 DEFINITION
                        LOCAL VARIABLE
    DATA ok_code TYPE sy-ucomm.
                          FOR VARIANT
    DATA st_var TYPE disvariant .
    DATA save TYPE c.
    st_var-report = 'YKC_ALV_OOPS_LOGO_DISPALY'.
    save = 'A'.
            FOR LAYOUT
    DATA loyo TYPE lvc_s_layo.
    loyo-zebra = 'X'.
    loyo-detailinit = 'X'.
    loyo-info_fname = 'RED'.
              FOR FIELD CATALOG
    DATA fcat TYPE lvc_t_fcat.
    DATA wa_fcat LIKE LINE OF fcat.
    *--Declaration for toolbar buttons
    DATA : ty_toolbar      TYPE stb_button.
    DATA : e_object        TYPE REF TO cl_alv_event_toolbar_set,
           io_alv_toolbar  TYPE REF TO cl_alv_event_toolbar_set.
    *---custom container
    DATA container TYPE REF TO cl_gui_custom_container.
    DATA ref_grid TYPE REF TO cl_gui_alv_grid.
    CREATE OBJECT container
      EXPORTING
        container_name = 'CONTAINER'."name of container in module pool
    CREATE OBJECT ref_grid
      EXPORTING
        i_parent = container.
          CLASS lcl_events_d0100 IMPLEMENTATION
    CLASS lcl_events_d0100 IMPLEMENTATION.
    *---method for hotspot
      METHOD handle_hotspot_click.
        DATA:ls_col_id   TYPE lvc_s_col.
        READ TABLE it_tab INTO wa_it_tab
                                 INDEX e_row_id-index.
        IF sy-subrc = 0.
          CHECK ( wa_it_tab-matnr IS NOT INITIAL ).
          CASE e_column_id-fieldname.
            WHEN 'MATNR'.
              leave program.
            WHEN OTHERS.
          do nothing
          ENDCASE.
          CALL METHOD ref_grid->set_current_cell_via_id
            EXPORTING
              is_row_id    = e_row_id
              is_column_id = ls_col_id.
        ENDIF.
      ENDMETHOD.                    "handle_hotspot_click
    **---method for handling toolbar
      METHOD handle_toolbar_set.
        CLEAR ty_toolbar.
        ty_toolbar-function = 'EDIT'. "name of btn to  catch click
        ty_toolbar-butn_type = 0.
        ty_toolbar-text = 'EDIT'.
        APPEND ty_toolbar    TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar_set
      METHOD handle_user_command.
        DATA: wr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
        DATA: lt_rows TYPE lvc_t_row,
              lt_index TYPE  lvc_s_row-index.
        CASE e_ucomm.
          WHEN 'EDIT'.
          perform save_database.
          CALL METHOD ref_GRID->REFRESH_TABLE_DISPLAY.
        ENDCASE.
      ENDMETHOD.                    "handle_user_command
    *---End of page
    ENDCLASS.                    "lcl_events_d0100 IMPLEMENTATION
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM field_catalog.
    *&      Form  get_data
          text : getting data into internal table
    -->  p1        text
    <--  p2        text
    form get_data .
      select matnr ersda ernam pstat lvorm mtart meins
             into table it_tab
             from mara
             where matnr GE '000000000000000001'.
    endform.                    " get_data
    *&      Form  field_catalog
          text
    -->  p1        text
    <--  p2        text
    form field_catalog .
      REFRESH fcat.
      DATA: lv_pos TYPE i.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-coltext = 'Material No'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-hotspot = 'X'.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'ERSDA'.
      wa_fcat-coltext = 'Creation Date'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-edit = 'X'.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'ERNAM'.
      wa_fcat-coltext = 'Person Created'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'PSTAT'.
      wa_fcat-coltext = 'Maint Stat'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'LVORM'.
      wa_fcat-coltext = 'Flag For Deletion'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'MTART'.
      wa_fcat-coltext = 'Material Type'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      lv_pos = lv_pos + 1.
      wa_fcat-fieldname = 'MEINS'.
      wa_fcat-coltext = 'UOM'.
      wa_fcat-col_pos = lv_pos.
      wa_fcat-outputlen = 18.
      APPEND wa_fcat TO fcat.
      CLEAR wa_fcat.
      CREATE OBJECT event_receiver1.
    *---setting event handlers
    SET HANDLER event_receiver1->double_click         FOR ref_grid.
      SET HANDLER event_receiver1->handle_toolbar_set   FOR ref_grid.
      SET HANDLER event_receiver1->handle_user_command  FOR ref_grid.
      SET HANDLER event_receiver1->handle_hotspot_click FOR ref_grid.
              ALV GRID DISPLAY
      CALL METHOD ref_grid->set_table_for_first_display
        EXPORTING
          is_variant      = st_var
          i_save          = save
          is_layout       = loyo
        CHANGING
          it_outtab       = it_tab[]
          it_fieldcatalog = fcat.
      CALL SCREEN 100.
    endform.                    " field_catalog
    *&      Module  STATUS_0100  OUTPUT
          text
    module STATUS_0100 output.
    create the custom container
        CREATE OBJECT pic_container
                      EXPORTING container_name = 'CUSTOM'.
    create the picture control
    create the picture control
        CREATE OBJECT picture
                      EXPORTING parent = pic_container.
    Request an URL from the data provider by exporting the pic_data.
        CLEAR url.
        PERFORM load_pic_from_db CHANGING url.
    load picture
        CALL METHOD picture->load_picture_from_url
          EXPORTING
            url = url.
       init = 'X'.
        CALL METHOD cl_gui_cfw=>flush
          EXCEPTIONS
            cntl_system_error = 1
            cntl_error        = 2.
        IF sy-subrc <> 0.
    error handling
        ENDIF.
    *---for editing
      CALL METHOD ref_grid->register_edit_event
      EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      SET PF-STATUS 'S100'.
      SET TITLEBAR 'XXX'.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  exit  INPUT
          text
    module exit input.
      CASE ok_code.
        WHEN 'EXIT' .
          CLEAR ok_code.
          LEAVE PROGRAM.
      ENDCASE.
    endmodule.                 " exit  INPUT
    *&      Form  SAVE_DATABASE
          text : saving into DDIC from internal table
    -->  p1        text
    <--  p2        text
    FORM SAVE_DATABASE .
    Getting the selected rows index
        CALL METHOD ref_grid->get_selected_rows
                    IMPORTING  et_index_rows = i_selected_rows.
    Through the index capturing the values of selected rows
        LOOP AT i_selected_rows INTO w_selected_rows.
        READ TABLE it_tab INTO wa_it_tab INDEX w_selected_rows-index.
        IF sy-subrc EQ 0.
          MOVE-CORRESPONDING wa_it_tab TO w_modified.
          APPEND w_modified TO i_modified.
        ENDIF.
      ENDLOOP.
      MODIFY mara FROM TABLE i_modified.
    ENDFORM.                    " SAVE_DATABASE
    *&      Form  LOAD_PIC_FROM_DB
          text : loading logo
         -->P_URL      text
    FORM load_pic_from_db  CHANGING p_url.
      DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
      DATA html_table LIKE w3html OCCURS 1.
      DATA return_code LIKE  w3param-ret_code.
      DATA content_type LIKE  w3param-cont_type.
      DATA content_length LIKE  w3param-cont_len.
      DATA pic_data LIKE w3mime OCCURS 0.
      DATA pic_size TYPE i.
      REFRESH query_table.
      query_table-name = '_OBJECT_ID'.
      query_table-value = 'ENJOYSAP_LOGO'.u201Dname of logo
      APPEND query_table.
      CALL FUNCTION 'WWW_GET_MIME_OBJECT'
        TABLES
          query_string        = query_table
          html                = html_table
          mime                = pic_data
        CHANGING
          return_code         = return_code
          content_type        = content_type
          content_length      = content_length
        EXCEPTIONS
          object_not_found    = 1
          parameter_not_found = 2
          OTHERS              = 3.
      IF sy-subrc = 0.
        pic_size = content_length.
      ENDIF.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type     = 'image'
          subtype  = cndp_sap_tab_unknown
          size     = pic_size
          lifetime = cndp_lifetime_transaction
        TABLES
          data     = pic_data
        CHANGING
          url      = url
        EXCEPTIONS
          OTHERS   = 1. *+
    Hope it helps you
    Regrds
    Mansi

  • Where used List for Packages (from Transport connection)

    Hi SDN,
    If objects , such as queries, or webtemplates, are incorrectly allocated to a BEx package at the beginning, my question is as follows:
    Can we find out which objects/queries/templates have been allocated to a particular package?
    Via some table, or where used list?
    As we have a global system, we are performing this task for many developers who have incorrectly used packages from the start.
    Thank you.
    Simon

    Hi Khaja,
    That is perfect!  I am tracking the various element objects
    ELEM
    TMPL
    QVIW
    etc...
    Would you happen to know if it is possible to mass change objects to the correct package and transport through.
    Thank you.
    Simon

Maybe you are looking for

  • Can't import video from Canon GL-2 into new Macbook Pro

    Can't import video from Canon GL-2 into new Macbook Pro Using 9-4 pin cable and then using firewire 800 to thunderbolt adapter.

  • How do I keep iPhone from dropping flagged messages ?

    I have flagged airline e-tickets, museum reservations, etc. on my iPhone inbox, and they disappear aftetr a few days to a week or more.  Where can I find them,or how do I keep them from disappearing ?  The only thing I do is to resend them from my co

  • HP Pavillion dv-7-6b55dx sound problems

    I just got my new laptop and Ive noticed that everytime I go on youtube, or i play music loud the sound cracks and it stops working good.. but there is no problem with it if its on very low volume, everytime I put the volume higher thats when it star

  • Connect iPad Sunday ticket to tv

    connect iPad Sunday ticket to tv? with HDMi ? does it work?

  • A BPM Question

    I want to develop a simple BPM example. In My scenario the input will be a File which has some data in it. The output should go to 3 different files. These output files generation is based on particular field in the input file structure. Input file w