}HTMLB FileUpload - Javascript

Hi SDN,
I am using
<hbj:fileUpload id="myfileupload"   />
in my jsp. I wanted to process the file that is to be uploaded in my javascript. There is no 'jsObjectNeeded'  attribute for the fileUpload UI element. How can I achieve this with SAP not supporting JS for this UI...any other round about way???
Please let me know...
Thanks & Regards,
p188071

Check this might hlep u
Thread
http://www.sapdesignguild.org/resources/htmlb_guidance/fileupload_dev.html
PDF
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/8a41cee4-0601-0010-5fb3-d8e704f88817?overridelayout=true
Thanks

Similar Messages

  • Com.sapportals.htmlb.FileUpload;

    Hi Experts,
    I am building this file upload utility.
    Following is my code"
    package com.xyz.ws.di;
    import java.io.Serializable;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.htmlb.FileUpload;
    import com.sapportals.portal.prt.component.*;
    import com.sapportals.wcm.repository.AccessDeniedException;
    import com.sapportals.wcm.repository.Content;
    import com.sapportals.wcm.repository.ICollection;
    import com.sapportals.wcm.repository.IResource;
    import com.sapportals.wcm.repository.NotSupportedException;
    import com.sapportals.wcm.repository.ResourceContext;
    import com.sapportals.wcm.repository.ResourceException;
    import com.sapportals.wcm.repository.ResourceFactory;
    import com.sapportals.wcm.util.uri.RID;
    import com.sapportals.portal.security.usermanagement.IUser;
    public class FileUpload implements Serializable{
             protected IPortalComponentRequest request;
              protected IPortalComponentResponse response;
              protected IPortalComponentSession session;
              protected IPortalComponentContext context;
              protected IPortalComponentProfile profile;
              protected String userId;
              protected String fileName;
              private DAO DAO = null;
              private final static int INITIAL_STATE = 0;   
              private final static int ERROR_STATE = 1; 
              private int state = INITIAL_STATE;
              public void uploadUtility(IPortalComponentRequest request, IPortalComponentResponse response)
                   String mimetype;
                   String resourceName;
                   String repository;
                   FileInputStream sourceFileInput = null;
                   session = request.getComponentSession();
                   DAO = new DAO();
                   DAO = (DAO)session.getValue("DAO");
                   IUser epUser=DAO.getEpUser();
                   System.err.println("berry + Getting Iuser from inside UploadUtility SAI  " + epUser);
              /*     IWDClientUser wdUser = WDClientUser.getCurrentUser();
                   IUser user = wdUser.wdUser.getSAPUser(); */
              //     IUser epUser=(IUser)request.getUser().getUser();
                   System.err.println("epUser - " + epUser);
                   ResourceContext ctx = new ResourceContext(epUser);
                   repository = "/Folder1/new";
                   RID rid=RID.getRID(repository);
                   System.err.println("getting RID :- " + rid);
                   IPageContext context = PageContextFactory.createPageContext(request,response);
              //     PageContext context = PageContextFactory.createPageContext(request, response);
                   Event event=context.getCurrentEvent();
                   if(null!=event)
                        String event_name=event.getAction();
                        if(null!=event_name && event_name.trim().equalsIgnoreCase("upload_file"))
                              FileUpload fileUpload = (FileUpload)context.getComponentForId("fileupload");
                                  if(null !=fileUpload && null!=fileUpload.getFile())
                                            mimetype = fileUpload.getFile().getContentType();
                                            resourceName = fileUpload.getFile().getFileName();
                                            System.err.println("resourceName inside fileUploadUtility :- " + resourceName);
                                            //sourceFileInput = new FileInputStream(fileUpload.getFile().getFile().getAbsolutePath());
                                            fileName = resourceName;
                                            System.err.println("filename :- " + fileName);
                                            try {
                                                 sourceFileInput = new FileInputStream(fileUpload.getFile().getFile().getAbsolutePath());
                                            } catch (FileNotFoundException fnf) {
                                                 state = ERROR_STATE;
                                                 System.err.print("FileNotFoundException Occured " + fnf.toString());
                                            Content content = new Content(sourceFileInput, mimetype, -1L);
                                            IResource resource = null;
                                            try {
                                                 resource =(IResource) (ResourceFactory.getInstance().getResource(rid, ctx));
                                            } catch (ResourceException resexp) {
                                                 state = ERROR_STATE;
                                                 System.err.print("Resource Exception Occured for IResource" + resexp.toString());      
                                            ICollection aCollection=(ICollection)resource;
                                            //IResource newResource = aCollection.createResource(resourceName, null, content);
                                            try {
                                                 IResource newResource = (IResource) aCollection.createResource(resourceName, null, content);
                                            } catch (NotSupportedException e2) {
                                                 state = ERROR_STATE;
                                                 System.err.print("Not Supported Exception Occured" + e2.toString());
                                            } catch (AccessDeniedException e2) {
                                                 state = ERROR_STATE;
                                                 System.err.print("Access Denied Exception Occured" + e2.toString());
                                            } catch (ResourceException e2) {
                                                 state = ERROR_STATE;
                                                 System.err.print("Resource Exception Occured for ICollection" + e2.toString());      
                                            }//end of catch
                             }//end of innermost if
                   }//end of 2nd if
              }//end of 1st If
              DAO.setFileName(fileName);
              DAO.setState(state);
              session.putValue("DAO", DAO);
           }// end of uploadUtil
    I am getting a complie error in my NWDS at the following line:
    FileUpload fileUpload = (FileUpload)context.getComponentForId("fileupload");
    The error is : Cannot cast from component to FileUpload.
    Also, I am getting an error on the following Import statement:
    import com.sapportals.htmlb.FileUpload;
    The error is : The import import com.sapportals.htmlb.FileUpload conflicts with a type defined in the same file.
    Any Idea why this would be happening?
    Thanks
    S.B

    import com.sapportals.htmlb.FileUpload;
    is conflicting with the class name. Both are same.
    Change the class name.
    Thread closed.

  • Maximum file size using htmlb:fileUpload

    Hello Gurus,
    in a bsp application we are using htmlb:fileUpload. It was possible to upload a 43 MB file without problem. But our maximum file size is about 220 MB. We made a test with a 190 MB file. After we hit the post button, the browser disconnects immediately (without timedelay) with the message: page cannot be displayed.
    for me it looks like we hit some restriction.
    any idears how to manage the 220 MB file in the browser beside splitting it into smaller files would be greatly appreciated.
    thx a lot in advance and regards from
    Michael

    Hello again,
    could it be this parameter which is for the limitation responsible ?
    icm/HTTP/max_request_size_KB   = 102400
    thx and best regards from Michael

  • Htmlb:fileupload

    Hi Gurus,
    In my custom BSP I'm using Htmlb element fileupload in the following way..
    <htmlb:fileUpload id          = "myFile"
                              accept      = "true"
                              size        = "50" />
    I'm able to select only a single file when I browse for files. How should I acheive seleting multiple files ?
    Thank you
    Sreesanth

    Hello Sreesanth,
    If you want ot upload more than one file, use <htmlb:fileUpload> that many times.
    Rgds,
    Jothi.P
    **reward and close the thread if useful.

  • htmlb:fileUpload in BSP

    Hi,
    Iam uploading an Excel file from the local PC using the <htmlb:fileUpload>
    I wanted to read this uploaded file and create a document with the data in the cells on the excel. When iam trying to read i get the data in numbers.
    any ideas to read the uploaded file.
    Thanks,
    Shailaja

    Hi Shailaja
    please try CL_HTMLB_MANAGER=>GET_DATA. For BSP related question you should search in the Business Server Pages (BSP).
    Regards
    Gregor

  • Htmlb:fileUpload = page connot be displayed

    I just tried to use a this item:
    <htmlb:fileUpload id="att_upload" size = "50" />
    However, as soon as I instert that item into my BSP page and try to start it (F8), i get an "page connot be displayed" error in the browser. does anybody know how to use that (or another similar) item?
    thx

    Hi Daniel,
    please try the following:
    open your browser, click on Tool -> Internet Options
    and then on the tabstrip 'Advanced'. Uncheck both entries starting with "Show friendly". Try to start your BSP again. You will get a more technical error message. This can be helpful in finding the error.
    Regards,
    Rainer

  • htmlb:fileupload goes into infinite loop

    Hello all,
    We use the tag <htmlb:fileupload> in our bsp page. Now if the user enters a file name directly, ie:without using the browse button the user simply enters a filename, say 'Resume.doc' in the input field and hits the save button on the page, then the system is going into an infinite loop and the system hangs, the users cannot proceed further and they need to restart the browser all over again(it is not necessary that the file must exist in the system, the user just types in a file name and performs the save action). This is a cause of concern for some of our customers, they expect that we should provide a meaningful message to the user and the processing should end. Is this a known issue in BSPs ?? Can anyone suggest me how to get rid of this problem ?
    Thanks and Best Regards,
    Viqar Ali.

    Hello All,
    I use the following code in my bsp:
    <phtmlb:matrix width="100%" >
      <phtmlb:matrixCell row = "1"
                         col = "1" />
        <phtmlb:formLayout design           = "HEADING_ONLY_SOLID"
                           customizationKey = "<%= controller->context %>" >
        <%-- Upload --%>
        <phtmlb:formLayoutItem label    = "<%= controller->file_label %>"
                               idOfItem = "upload" >
          <htmlb:fileUpload id   = "upload"
                            size = "30" />
        </phtmlb:formLayoutItem>
    Everything works fine if the user selects a file using the browse button to select a file. Instead if the user enters a file name directly, then the system runs into an infinite loop. I have put a breakpoint in DO_HANDLE_DATA & DO_REQUEST of the controller class. However the control doesnt come till this point also and i cannot even debug anything. The breakpoints are hit if the user selects the file using the browse button. If anyone has a similar scenario working correctly in their application pls update me with the code.
    Thanks and Best Regards,
    Viqar Ali.

  • Set default file for htmlb:fileUpload ?

    I use htmlb:fileUpload to let the user select a file from the file system.
    Is it possible to write a start value into the textbox??
    For example, I'd like to write "C:\Windows\text.txt" into the inputField when the page is first shown.

    <i>> I'd like to write "C:\Windows\text.txt"</i>
    In short words: this is not allowed because it is not secure.
    Nobody but user itself can changer something in the file upload control.
    Consider the example
    <fileupload default="C:\Windows\passwords.etc">
    and autosubmit

  • How to hide htmlb fileUpload

    Hi all,
    If i have not authorization to upload a file then  i need to hide the element htmlb fileUpload . How can i do it?. Thanks in advance.
    Gab.

    Hi Gab,
    check this link
    upload file via BSP
    cheers,
    Bhavana

  • Accessing HTMLB from javascript

    Hi expert,
    Can someone explain how to access the attributes,methods avialable in javascript to access htmlb objects in a page,
    Like for e.g.,
    htmlbSL(this,2,'SUBMITVALUES:HandleSubmit')
    Is there any document available?
    Thank you
    AP

    Hi AP,
    I believe there is no documentation avaliable about this.
    Maybe because this accessing method is not right to do
    but I can explaint about the function htmlbSL
    function htmlbEL(this,2,'SUBMITVALUES:HandleSubmit');
    this                      = HTML element.
    2                         = event type index.
    SUBMITVALUES:HandleSubmit = objectID:eventName
    if you want to know list of event type index.
    here the list:
    <b>EVENT TYPE                  INDEX</b>
    'htmlb:breadCrumb:click'      1
    <b>'htmlb:button:click'          2</b>
    'htmlb:checkbox:click'        3
    'htmlb:image:click'           4
    'htmlb:link:click'            5
    'htmlb:radioButton:click'     6
    'htmlb:tabStrip:click'        7
    'htmlb:tree:click'            8
    hope this can help you.
    respeck,
    -adyt-

  • HTMLB and JavaScript

    Hi,
    I am using HTMLB in my JSP page.Is there any way to hide or show the HTMLB components when the page is loaded, like HTML onLoad() calling javascript.
    expecting some sample code from HTMLB experts.really i stuck wih this problem for 2 days.
    For example.....i have one DropdownList box.Based on the selected dropdown values ,i need to show and hide one InputField and another Dropdown.
    Regds,
    Jeyanth

    Hi,
    You can achive this in two ways.
    1) client side :
    Have the dynamic fields in style sheet.Sho or hide based on the value selected.
    Please find below code:
    In your drop down list box : mention onclientselect = dispaly()
    <SPAN ID=ss Style="Visibility:hidden;
                       Filter:revealTrans(duration=0)">
    <!-- Your field --!>
    </SPAN>
    <-Javascript>
    function display()
    if ( vlaue ==1 )
      ss.style.visibility = "visible";
    else
      ss1.style.visibility = "visible";
      ss.style.visibility = "hidden";
    // ss1 is style sheet 2 where in which ur second field is placed
    the above code may cause some problem in netscape browsers. But it can be resolve by handling stylesheet properly.
    2) Server side:
    in the dropdown mention onselect = display()
    in your dynpage class mention display() method.
    Have two variables in bean for each field.
    set those fields hide or show based on the value.
    Put your field
    <%
    if ( flag == true )
    your field 1
    else
    your field 2

  • Access to HTMLB with JavaScript in DynPage class

    Hi, in the documentation JavaScript API of SAP HTMLB Guidelines there is an example code in 4 parts.
    1.
    Form form = (Form)this.getForm();
    nputField inf2 = new InputField("currencyDisplay");
    inf2.setJsObjectNeeded(true);
    inf2.setClientEvent(EventTrigger.ON_CHANGE, "calculateCurrencyToFrom()");
    inf2.setBCD("100");
    inf2.setWidth("250px");
    form.addComponent(inf2);
    2.
    function calculateCurrencyFromTo() {
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    var inputfield = eval(func("currencyDisplay"));
    if (inputfield)
    inputfield.setValue("100.23"); }
    3.
    InputField inf2 = new InputField("currencyDisplay");
    String inputfieldID = pageContext.getParamIdForComponent(inf2);
    4.
    <script> var inputfield = eval(inputfieldID);</script>
    I try to run this code in DynPage class. I put the code part 1 in doBeforeProcess(), then use form.addRawText() to send JavaScript code to client.
    <script> var inputfield = eval(inputfieldID);
    function calculateCurrencyFromTo(){
    var funcName = htmlb_formid+"_getHtmlbElementId";
    func = window[funcName];
    var inputfield = eval(func("currencyDisplay"));
    if (inputfield)
    inputfield.setValue("100.23");}
    </script>
    question:
    Where to put the part 3 in order to detect the input field is selected or triger the event? Thank you for help.
    Yantong Wang

    Hi Raymond,
    Try out the following piece of code (the code is tested and is working):
    <hbj:textEdit      id="addComments"
                        wrapping="SOFT"
                        text=""
                        rows="2"
                       cols="100" >
         <% addComments.setJsObjectNeeded(true); %>
    </hbj:textEdit>
    Then through javascript you can access the id of the text edit in the similar fashion.
    var txtAdCom= eval(func("addComments"));
    var value =txtAdCom.getValue();
    var length = txtAdCom.getValue().length;
    Please do reward with points if the solution is helpful.
    Thanks
    Ritushree

  • Problems with htmlb:fileUpload

    Hi, I am trying to implement a JSPDynPage which uses the
    fileUpload-Tag. In most cases it works fine but sometimes I can select a file but the next button click (onWork) event is not send to the server.
      <hbj:form id="myForm" encodingType="multipart/form-data">
      <hbj:formLayoutCell id="cf_fimport_2" align="center"  valign="TOP" width="175">
         <hbj:fileUpload id="upload" size="30" accept="plain/text"/>
      </hbj:formLayoutCell>
    and the button is defined
    <hbj:formLayoutCell id="cf_fimport_5" align="right" paddingRight="7">
      <hbj:button id="bpreview" text='doWork' design="STANDARD" disabled="false"
    onClick="work"/>
    </hbj:formLayoutCell>
    The page is refreshed but no action is done.
    Any idea?
    Is there a bit more documentation about the fileUpload-Tag ?
    Environment:
    Windows XP
    SAP EP6 SP4 Sneak Preview
    IE 6.0
    Regards
    Edmund

    Dear Edmund.
    I've exactly the same problem.
    In details:
    Prerequisites:
    1) there is <hbj:fileUpload ...> tag on the jsp.
    2) The form is declared as <hbj:form id="....." encodingType="multipart/form-data">
    3) There is defined button with handled event e.g. "onButtonClicked"
    4) The user will insert any file to the tag
    Behavior:
    1) The request does NOT consist ANY components. ( I can see in the log )
    2) The method "onButtonClicked" is NOT called.
    3) Randomly - there is onInitialization() method called.
    As it was mentioned by You, the older versions of portal works with the hbj:fileUpload correctly.
    I will be very pleased with someone explaining the problem.
    Regards Best
    Marek
    P.S.Very interesting fact: when <the hbj:fileUpload> is empty the request is sent properly - with all the components.

  • Htmlb:fileUpload: change "browse" button to another language

    I have a simple fileUpload Tag that shows a inputField and a "Browse" Button. In my Browser-Settings, the language is German, so instead of "Browse", there should be something in German.
    Can I change that word somehow?

    Hi Daniel,
    A very good hack has been found out for the same. Look at this weblog...
    /people/dagfinn.parnas/blog/2004/08/15/inputfile-how-to-hide-the-plain-browse-button
    I am sure you can find a way out from this and please let us know, your approach as well
    Regards,
    Subramanian V.

  • HTMLB and Javascript: Dependent Checkboxes

    Hello Collegues,
    i try to programming a search component with some dependent checkboxes. For example the user should check "checkbox 1" and there should be "checkbox 2" also selected.
    I write this small example for this. But it dont works. I thing i have an mistake in the onClientClick function. Does somebody knows the right way to do this?
    public class SearchLocalization extends AbstractPortalComponent
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
              //response.write("Javascript Checkbox Test<br>");     
              IPageContext myContext = PageContextFactory.createPageContext(request, response);
              if (myContext == null) {
                   response.write("myContext == null");
              Form myForm = myContext.createFormDocument("Javascript Checkbox Test");     
              GridLayout gl = new GridLayout();          
              Checkbox one = new Checkbox("one");
              one.setText("One");          
              gl.addComponent(1,1,one);
              Checkbox two = new Checkbox("two");
              two.setText("two");     
              gl.addComponent(1,2,two);
              myForm.addComponent(gl);
              two.setOnClientClick("javascript:one.checked = true;");          
              myContext.render();                    
    Best regards,
    Patrick

    Hi Patrick,
       Create a JSPDynPage and in the jsp, u can code javascript like this. I just checked and it is working for me.
    <%@taglib uri="tagLib" prefix="hbj"%>
    <hbj:content id="myContext" >
      <hbj:page title="PageTitle">
        <script language="javascript">
       function checkme(){
                 var funcName = htmlb_formid+"_getHtmlbElementId";
             func = window[funcName];
             var check1 = eval(func("Check1"));
             var check2 = eval(func("Check2"));
            var check1status = check1.getChecked();
            if(check1status==true){
                   check2.setChecked(true);
      </script>
       <hbj:form id="myFormId" >
          <hbj:checkbox
                   id="Check1"
                   text="Check1"
                   tooltip="Check1"
                   disabled="false"
                   checked="false"
                   jsObjectNeeded="true"
                   onClientClick="javascript:checkme();"
             />
         <hbj:checkbox
          id="Check2"
          text="Check2"
          tooltip="Check2"
          disabled="false"
          jsObjectNeeded="true"
          checked="false"
        />
       </hbj:form>
      </hbj:page>
    </hbj:content>
    Regards,
    Harini S

Maybe you are looking for

  • Sharing Internet with windows, connected by ethernet, using mac's airport

    So I have a desktop that doesn't have Wi-Fi and I too cheap to buy anything for it. So I'm trying to use the MacBook's airport to give the Windows internet through the ethernet connecting them both. I went to internet sharing and entered "Share conne

  • Refreshing Presentation on JSP App

    I've got problem with refreshing data in presentation. During watching data in my bibeans application somebody changed data in cube using another application (AWM for instance). Now i want to refresh data in bibeans. I tried to use this code. Present

  • Can't read PDF's on the web

    Hi, I'm trying to read PDF's hosted on the web, but all I get when I click to open is a page full of characters and symbols. I know the PDF's themselves are fine as my colleage is able to view them on their machine. I've tried viewing in Safari (I us

  • Unable to find start updisk

    Hi there , Can anybody help? i have done a restore on my new macbook pro from time machine which was from my white macbook. when i select the start up disk on my pro it goes to restart but doesn't seem to find anything then restarts again. I have loo

  • Service Tax Number

    Hi Frnds, Where should we maintain the service tax number of the vendor in the vendor master ?