FileDownload UI Element in a table

I'm tryign to use FileDownload UI Element in a table, but it seems not to work.
I have defined a binary, an IWDAttributeInfo and a IWDModifiableBinaryType attributes in the same context node of the table.
In wdDoInit() I wrote the following code:
for (int i=0;i<wdContext.nodeFileTab().size();i++)
try {
wdContext.nodeFileTab().getFileTabElementAt(i).setAttInfo(wdContext.nodeFileTab().getNodeInfo().getAttribute(IPrivateView_pdfView.IFileTabElement.T_FILE_DOWNLOAD));
wdContext.nodeFileTab().getFileTabElementAt(i).setBinaryType((IWDModifiableBinaryType)wdContext.nodeFileTab().getFileTabElementAt(i).getAttInfo().getModifiableSimpleType());
wdContext.nodeFileTab().getFileTabElementAt(i).getBinaryType().setFileName(wdContext.nodeFileTab().getFileTabElementAt(i).getFilename());
wdContext.nodeFileTab().getFileTabElementAt(i).getBinaryType().setMimeType(WDWebResourceType.PDF);
wdContext.nodeFileTab().getFileTabElementAt(i).setTFileDownload(this.getByteArrayFromResourcePath("/sapmnt/PCD/global/config/cm/etc/pdf/"+wdContext.nodeFileTab().getFileTabElementAt(i).getFilename()));
catch (Exception e)
wdComponentAPI.getMessageManager().reportException(e.toString(),true);
As result each row download the file in the last row. Is there any other way I can try?

Hi Anita,
you cannot set metadata at element level of a node. When you set the metadata ( example mime type or file name ) for a particular element in the node , it changes for all the element. So you are always getting the file for the last row. ( most recent set metadata ).
Try using the inteface IWDCachedWebResource for file download.
For each row add a button, and associate an action "DownloadFile" for it. Use the following "onAction" for the said action. 
public void onActionDownloadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionDownloadFile(ServerEvent)
    int selectedIndex = wdContext.nodeFileTab().getLeadSelection();
    IPrivateView_pdfView.IFileTabElement file = wdContext.nodeFileTab().getFileTabElementAt(selectedIndex);
    try {
     IWDCachedWebResource webResource = WDWebResource.getWebResource(
          this.
          getByteArrayFromResourcePath("/sapmnt/PCD/global/config/cm/etc/pdf/"+
          wdContext.nodeFileTab().getFileTabElementAt().getFilename(selectedIndex),
          WDWebResourceType.PDF);
     wdComponentAPI.getWindowManager().createExternalWindow(webResource.getURL(),"Download File",true).open();
   catch(Exception e) {
     // take some action
     wdComponentAPI.getMessageManager().reportException(e.toString(),true);
    //@@end
Hope you get a solution.
Regards
KK.

Similar Messages

  • How to implement the filedownload UI Element as table cell editor

    hi guyes,
       now i want to add the filedownload ui element in the table. i choose to apply template to insert table and bind the table to a Model Node . should i build a attribute of binary in the model node and bind it to filedownload ui element? when i
    do the above , in the "table binding wizard"  what should i choose under the colum of " binding property"? can any body send me the same example code to me?
    e-mail address:[email protected]  
      Thanks A Million !

    Hi
    Exactly to your requirement
    <b>Tutorial</b> https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f
    <b>Forum Thread</b> 2004s file download (how to not store files in context?)
    Regards
    Abhijith YS

  • Get selected elements from a table

    Hi all,
    I have a requirement like i m enhancing standard component in that i have added one button on click of that i want fetch the selected line item from the table ( which is a normal table). selection mode is auto.
    i tried with  the following code.
    DATA:lr_element                   TYPE REF TO if_wd_context_element,
           lv_index                     TYPE i.
    *--Get selected element
      lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
    ****Here itself its throughing dump because lr_element is initial***************
    *--get selected element index.
      lv_index = lr_element->get_index( ).
    can any one help me what is the wrong.. else suggest me how to get the selected elements from a table....
    Thanks in advance.

    *--Get selected element
    lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
    if  lr_element is bound.
    lv_index = lr_element->get_index( ).
    endif.
    Instead you can directly read the node if that row is a lead selected one.
    lo_node = wd_context->get_child_node( name = 'EMP' ).  "Emp is node name
    lo_ele = lo_node->get_lead_selection( ).
    or
    lv_index = lo_node->get_lead_selection_index( ).
    where is the above code written..is it written in OnLeadSelect event of the TABLE..
    can any one help me what is the wrong.. else suggest me how to get the selected elements from a table....
    As the selection mode is Auto there is no multiple selection..hence try to use the lead selection only.
    Edited by: Lekha on Jan 3, 2012 6:47 PM

  • Unable to download file from FileDownload UI Element - Java Web Dynpro

    Hello Experts,
    I am facing a strange issue.Scenario is:
    I created an java web Dynpro application (Please note that it is just a standalone WD app, not integrated in portal) with just one FileUpload UI Element ,one FileDownload UI element and one button (for triggering an action).
    I browse a file (e.g. text,pdf,doc etc.) and click on button. It uploads the file and when I click on download, there are two cases:
         1) Simply click on download does not downloads the file and shows error: "Unable to download <file name> from <server name>.  Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later." Though it is opening the file,showing the content.
         2) I opened that portal URL in a new tab in same session and logged in with a portal user. Now if I click on download link of same WD app opened in different tab of same session, it downloads the file without any error.
    I am using portal 7.0
    Can somebody point what's going wrong with case 1?
    Helpful pointers will be appreciated.
    Thanks,
    Kirtiman

    Hi Sid,
    I did not gave any authentication of WD app as it is anonymous app. There is no parameter set in application properties.
    As I run the app, it is showing the initial screen with UI elemtns and till upload works fine,.It has to be an anonymous app, so cannot ask for credential from user.
    Thanks
    Kirtiman

  • How to get Index of a single element in a table

    Hi Gurus,
    I need to get the index number of the element in a table even if the row is not selected.
    I've already searched the forum for this but all i'm getting are selected rows in the table.  I need to get the index even if that elemen's row is not selected in the table.
    Please advise.
    Regards,

    Hi,
    Could you please specify what exactly you want to do?
    You said you want to get the index of an element even if the corresponding row is not selected. But there might be more than one element where the correponding rows are not selected. So it would be better if you could be more specific about what you want to achieve.
    Regards,
    Srilatha

  • How to insert a text edit UI element  in a table

    hi all,
    I want a text edit UI element in a table .I do not want input field because text entered can be very long and whole text cant be seen then.Is there any way to increase the width of input field if i insert an input field ? or what can be other solution for this?

    Hi Govind,
    You can't insert Text Edit as a cell variant in table. But you can increase the 'Width' property of Input Field, say to 500px or as per your requirement, so that you can display the full text at one go. Or you can bind the 'Width' property to a context and set the width at run time as per the text length.
    Thanks,
    Sumit

  • Regarding Link to URL UI Element in a table

    Hi All,
    I am using "link to url" UI Element in a table column. I have mapped the column (i mean the "reference" property of "link to url" UI to a bapi node). Now, when I am populating the table, for some rows the bapi is not returning the url links. So, the column is getting disabled and not even showing the links for the rows which are getting the url link from the bapi.
    Is there any way to set the mapping row wise, so that the rows which have data get enabled with the link and which do not have data will be disabled.
    Also, can I make the whole table readonly, except for one column.
    Please help me in this regard.
    Regards,
    Murthy.

    Hi Armin,
    Thank you very much. The problem is solved. 10 points for you.
    Another Question.......
    Can we make the table readonly, leaving just one column to select.(that is the column with link to url). Is it possible? If so, please tell me how....
    Also, can you tell me the reason for the following exception.....
    <b>com.sap.tc.webdynpro.progmodel.context.ContextConfigurationException: DataNodeInfo(CreateTemplateComp.Zad_Bapi_Get_Template_Details_Input.Output.T_Template_Details): structure field Ad_Height not found
        at com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo.init(DataAttributeInfo.java:299)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initUnmappedAttributes(NodeInfo.java:687)
        at com.sap.tc.webdynpro.progmodel.context.DataNodeInfo.doInit(DataNodeInfo.java:238)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:671)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:674)
        ... 49 more</b>

  • Insert a new Dropdown UI-Element in a Table header

    Hello,
    i need to insert a Dropdown UI-element in a Table header, i was looking in the forum and the Web, BUT i didnt find anythinf that can help.
    please schow me how can I insert a DropDown UI-Element in the Header.
    thank you all

    Hello,
    You can normally create a table. Insert a table column and for the table column you need to give Dorpdown by Key / index as a cell editor.
    Thanks,
    Raju Bonagiri

  • Clickable UI element in a table tree as a child

    Hi experts,
    I haev created a tree in a table column. And in a treebykeytable coumn of a table, what type of cell editor can be included so that we can capture a event on a click of it.
    I.e once a child is clicked- I want to caoture the value of child clicked and navigate further.
    I dont want to use linktoaction UI element and moreover table need initialze lead selection and on using linktoaction, for clicking any child it capture only root value i.e lead selected by default.
    Thanks
    Depesh

    https://www.sdn.sap.com/irj/sdn/nw-70
    would help you
    regards
    nag

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • Filedownload UI element not working in production

    Hi,
    There is filedownload UI element used along with a dropdown UI element
    This is working fine in dev and quality but in production it doesnt pick the file.
    It is made to work as follows -
    u2022     first of all the files are placed at root location of the file system of server (filedownload ui element is used to download these files)
    u2022     The data and resource properties of the filedownload are populated upon the action of dropdown ui element
    u2022     so user has to select the dropdown frst and then click on filedownload UI element (which is a link)
    u2022     Following code is onaction of the dropdown ui element.
    byte b[];
              try {
                   String excelpath = null;
                     String systemID = System.getProperty("SAPSYSTEMNAME");
                     String appDir = System.getProperties().getProperty("Applications Directory");
    //                    if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Financial Forms - 1")               
    //                                  excelpath = "/usr/sap/"systemID"/JC00/j2ee/cluster/server0/apps/sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Financial Forms - 1.xls";  
    //              if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Financial Forms - 2")                          
    //                                     excelpath = "/usr/sap/"systemID"/JC00/j2ee/cluster/server0/apps/sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Financial Forms - 2.xls";                     
    //                   if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Non Financial Forms")                               
    //                                     excelpath = "/usr/sap/"systemID"/JC00/j2ee/cluster/server0/apps/sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Non Financial Forms.xls";          
                   if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Financial Forms - 1")               
                                    excelpath = appDir+"sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Financial Forms - 1.xls";  
                     if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Financial Forms - 2")                          
                                    excelpath = appDir+"sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Financial Forms - 2.xls";                     
                   if(wdContext.currentExcelName_downloadElement().getExcelName()=="Template for Non Financial Forms")                               
                                    excelpath = appDir+"sap.com/com.sap.engine.docs.examples/servlet_jsp/_default/root/Template for Non Financial Forms.xls";          
                   //wdComponentAPI.getMessageManager().reportSuccess(excelpath);
                    File input = new File(excelpath);                                           
                     int length =(int)input.length();
                //       Create a byte array b to hold the file
                     b = new byte[length];
                     FileInputStream in = new FileInputStream(input);
                //       Reading the file to a byte array b
                     in.read(b);
                     in.close();          
                //       Setting the data from the byte array to the context element.
                     wdContext.currentContextElement().setData_filedownload(b);
              //      Populating the resource attribute 
                  String filename = wdContext.currentExcelName_downloadElement().getExcelName();                 
                   IWDResource resource = WDResourceFactory.createResource(b, filename, WDWebResourceType.XLS);
                   wdContext.currentContextElement().setResource_filedownload(resource);
                } catch (FileNotFoundException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (IOException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
    This is working fine in all systems but after I deployed the code in production system it doesnt work. When user clicks on filedownload it doesnt open up any file download dialog box
    when similar problem occured in quality it was because the files were not placed at proper location
    but now the files are properly places i checked along with basis
    kindly advice what could be the problem here
    does it not determine link correctly or what could be difference betw non-production and productio environment ?
    thanks in advance

    Hi,
    Did you check the user permssions on the seected directory? The loged-in user should have at least reading permissions.
    Regards,
    Alain.

  • How to get selection screen elements and its table reference of a report ?

    halo experts
    How can I get selection screen elements and its table reference of a report ? . I tried rs_refresh_from_select_options. But I am unable to get the table and field it is referring to
    For eg if my selection screen 1000 is
    parameters: p_carrid type spfli-carrid,
    select-options :s-_connid type sflight-connid.
    is there any Fm or method which gives me what are the screen elements( p_carrid and s_connid ) and what table( splfi and sflight ) and field ( carrid and conid )it is referring to ?

    The following code is an example of how you might dynamically determine all your PARAMETERS and SELECT-OPTIONS variables at run time.  The PARAMETERS and SELECT-OPTIONS only point to a dictionary element--not a specific table.  Even though you may say "spfli-carrid" or "sflight-connid", the data type really references the dictionary type and not a specific table/structure.
    REPORT  ZTEST_PROG.
    TABLES sflight.
    DATA:
           screen_tab TYPE STANDARD TABLE OF screen,
           wa_screen TYPE screen,
           scrn_nm TYPE string,
           scrn_leftover TYPE string,
           l_type TYPE REF TO cl_abap_typedescr,
           typ_nm TYPE string,
           typ_pre TYPE string.
    FIELD-SYMBOLS <fs_data> TYPE ANY.
    PARAMETERS p_carrid TYPE spfli-carrid.
    SELECT-OPTIONS s_connid FOR sflight-connid.
    INITIALIZATION.
      LOOP AT SCREEN.
        IF screen-group3 = 'PAR'
          OR screen-group3 = 'LOW'.
            APPEND screen TO screen_tab.
        ENDIF.
      ENDLOOP.
    START-OF-SELECTION.
      LOOP AT screen_tab INTO wa_screen.
        ASSIGN (wa_screen-name) TO <fs_data>.
        l_type = cl_abap_typedescr=>describe_by_data( <fs_data> ).
        IF wa_screen-group3 = 'LOW'.
          SPLIT wa_screen-name AT '-' INTO scrn_nm scrn_leftover.
          TRANSLATE scrn_nm TO UPPER CASE.
        ELSE.
          scrn_nm = wa_screen-name.
        ENDIF.
        SPLIT l_type->absolute_name AT '=' INTO typ_pre typ_nm.
        WRITE:
                 / 'Screen Name:  ', scrn_nm,
                 / 'DDIC Type:    ', typ_nm.
      ENDLOOP.
    When you get into defining internal tables you can determine those at run time with cl_abap_structdescr.  The following is an example of how you might do that.  You can loop through the "components_table" and evaluate each field of the structure in this way.
    DATA: structure_reference TYPE REF TO cl_abap_structdescr,
          components_table TYPE abap_compdescr_tab,
          components_structure LIKE LINE OF components_table.
    structure_reference ?= cl_abap_structdescr=>describe_by_data( any_structure ).
    components_table = structure_reference->components.
    I don't know if this answers any of your questions but I hope that some of it is useful.

  • Create event on click of FileDownLoad UI Element

    Hi,
         I have created an interactive form whose initial visibility is set the false. I have a
         FileDownload UI element. Ideally on the click of the FileDownload UI,  I should
         be able to see the interactive form in the same view. Please help me out.
    Thanks,
    Prasanna

    Hi,
    FileDownload UI does not have any action property.
    In this case you have to have a UI element with which you can assocaite an action.
    In that action set the visibility of the InteractiveForm UI element to visible.
    For the visiblity
    1. First create a context attribute visibility of data type com.sap.ide.webdynpro.uielementdefinitions.Visibility
    2. Bind the context attribute with visible property of the InteractiveForm UI element.3. In wdDoInit of the view
    wdContext.CurrentnContextElement.setVisibility(IWDVisibility.Blank);
    3. In the action wdContext.CurrentnContextElement.setVisibility(IWDVisibility.visible);

  • REG: How to add elements onto htmlb table cell.. URGENT PLZ HELP

    Hi all,
    I have created a htmlb table. And the jsp code is as follows
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="application" class="com.linde.myaccounts.util.TableBean" />
    <hbj:content id="myContext">
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
       <hbj:tableView id="myTableView1"
                          model="myBean.model"
                          design="ALTERNATING"
                          headerVisible="false"
                          footerVisible="false"
                          fillUpEmptyRows="true"
                          visibleFirstRow="1"
                          visibleRowCount="5"
    </hbj:form>
      </hbj:page>
    </hbj:content>
                          width="500 px" >
    </hbj:tableView>
    I have used a table bean by which I am getting the column header names. I have 5 columns, I have to add input field in the first column, checkbox in the second column, leave the third column blank, checkbox in the fourth column and again a input field in the fifth column. I am not understanding on how to add this elements onto the table. Will I add it from the JSP using <hbj:tableViewColumns> tag or I have add them in the bean or in the dynpage. Kindly someone give me the code for this...
    This is very urgent..Kindly help...
    Thanks in advance,
    Priyanka

    Hi,
    Have you tried looking at the examples that come with the PDK for all of the HTMLB elements?  From memory, there should be a small table example or 2 that have different types of columns shown similar to what you want - they have the full source code with them for you to look at.
    If you are working in a portal, go to the Java Developer tab and I "think" there should be a tab linking to HTMLB documentation and examples - sorry I can't be more specific but I don't have access to a portal at the moment so am trying to remember.
    Gareth.

  • Read elements of a table

    HI all,
             I have a table with about 100 rows and 6 columns. I want to read each and every element of the table for implementing some checks and using each of them individually further. Could you please help me, how to do so.
    Cheers Umang

    Hi,
    use the following code choose one of them based on your requirement
    code is based on the node called "Orders" and its Elements so you need to change this according to yours
    for(int x=0; x<wdContext.nodeOrders().size(); x++)
                //Generic Approach
                IWDNodeElement element = wdContext.nodeOrders().getElementAt(x);
                Object obj = element.getAttributeValue("<Your Attribute Name>");
                //Typed Approach
                IOrdersElement element2 = wdContext.nodeOrders().getOrdersElementAt(x);
                String type = element2.getOrderType();
    Regards
    Ayyapparaj

Maybe you are looking for