JSF upload driving me crazy

Hello all,
I've been working with JSF for some months now, and I even made a few 'kinda' working upload implementations. But it never works perfect.
Could anyone please put a working example online. I have only to requirements: I should be able to retrieve the original filename and should be able to upload large (100m+) files.
Thank you very much!!!

If you use MyFaces, you can use this code:
<h:form name="formUpload" enctype="multipart/form-data">
     <h:panelGrid
        id="gridUpload"
        columns="2">
       <f:facet name="header">
            <h:outputText value="Upload do Arquivo de Arrecada��o"/>
       </f:facet>
        <h:outputLabel
           for="uploadFileField"
           value="File:"/>
        <t:inputFileUpload
           id="uploadFileField"
           value="#{uploadBean.file}"
           storage="file" required="true"/>
       <f:facet name="footer">
             <h:commandButton
                id="bottonUpload"
                value="Send"
                action="#{uploadBean.upload}"
                styleClass="BUTTON"/>
       </f:facet>
     </h:panelGrid>
</h:form>
   private UploadedFile file;
   public UploadedFile getFile()
      return file;
   public void setFile(UploadedFile file)
      this.file = file;
   public String upload()
      String fileName = file.getName();
      long fileSize = file.getSize();
      String fileStr;
      try
         fileStr = new String(file.getBytes());
      catch (IOException e)
         String errMsg = e.getMessage();
         FacesContext.getCurrentInstance().addMessage(
               "ERROR",
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                     "Erro ao carregar arquivo", errMsg));
         return "ok";
   }

Similar Messages

  • JSF layout driving me crazy!

    I've been working hard on a jsf powered project manager and am running into some problems with IE compatability. I got everything aligned and positioned the way (more or less) I wanted it, but when I tested it against IE all hell broke loose (specifically with the dateInput component). I took a few screen shots to explain my problem...
    What it looks like in Firefox: http://img6.imagepile.net/img6/91064firefox.png
    What it looks like in IE: http://img6.imagepile.net/img6/76581ie.png
    Each div outlined for refrence: http://img6.imagepile.net/img6/77815sh.png
    (keep in mind the design is still in development)
    CSS:
    body {
            padding: 1em;
            font-family: georgia, times, "times new roman", serif;
            color: #000;
    img {
            border:0px;
    .container {
            border: 1px solid #333;
            overflow: auto;
    .banner {
            background-color: #666;
            border-bottom: 1px solid #333;
    .banner h1 {
            margin: 0;
            padding: .5em;
    .side {
            float: right;
            margin-right: 2em;
            padding-top: 1em;
            padding-bottom: 1em;
            overflow: auto;
            height: 400px;
    .sectionHeader {
            text-align: center;
            padding-bottom: 1em;
    .side p {
            margin-top: 0;
    .content {
            float: left;
            margin-right: 1em;
            padding-top: 1em;
            padding-bottom: 1em;
            margin-left: 2em;
            overflow: auto;
            height: 400px;
    .content h2 {
            margin-top: 0;
    .footer {
            clear: both;
            background-color: #666;
            text-align: center;
    .pageHeader {
            text-align: center;
            padding-top: 1em;
    }JSF Code:
        <%@include file="WEB-INF/inc/imports.inc"%>
        <html>
        <head>
                <title>LS Project Manager - Project Creation Wizard</title>
                <link rel="stylesheet" href="css/master.css" type="text/css" />
                <link rel="stylesheet" href="css/tabbedPane.css" type="text/css" />
        </head>
        <body>
        <f:view>
                <t:saveState value="#{pcwBacker}"/>
                <t:div styleClass="container" id="container">
                        <%@include file="WEB-INF/inc/navigationbar.inc"%>
                        <t:div styleClass="pageHeader" id="pageHeader">
                                <t:outputText value="Project Creation Wizard"/>
                        </t:div>
                        <t:div styleClass="content">
                                <t:panelTabbedPane styleClass="tabbedPane"
                                                activeTabStyleClass="activeTab"
                                                inactiveTabStyleClass="inactiveTab"
                                                disabledTabStyleClass="disabledTab"
                                                activeSubStyleClass="activeSub"
                                                inactiveSubStyleClass="inactiveSub"
                                                tabContentStyleClass="tabContent"
                                                serverSideTabSwitch="false"
                                                selectedIndex="#{pcwBacker.currentIncompleteStep - 1}">
                                        <h:form></h:form> <!-- Addresses weird bug. Do not remove! -->
                                        <t:panelTab label="General Information">
                                                <h:form>
                                                <t:panelGrid columns="3">
                                                        <h:outputText value="Name: "/>
                                                        <h:inputText id="name" value="#{pcwBacker.name}" required="true" />
                                                        <t:message forceSpan="true"  for="name"/>
                                                        <h:outputText value="Category:"/>
                                                        <h:selectOneMenu id="category" value="#{pcwBacker.category}" required="true">
                                                                <f:selectItems value="#{pcwBacker.categoryItems}"/>
                                                        </h:selectOneMenu>
                                                        <t:message forceSpan="true"  for="category"/>
                                                        <h:outputText value="Status:"/>
                                                        <h:selectOneMenu id="status" value="#{pcwBacker.status}">
                                                                <f:selectItems value="#{pcwBacker.statusItems}"/>
                                                        </h:selectOneMenu>
                                                        <t:message forceSpan="true"  for="status"/>
                                                        <h:outputText value="Phase: "/>
                                                        <h:selectOneMenu id="phase" value="#{pcwBacker.phase}">
                                                                <f:selectItems value="#{pcwBacker.phaseItems}"/>
                                                        </h:selectOneMenu>
                                                        <t:message forceSpan="true"  for="phase"/>
                                                        <h:outputText value="Date Due: "/>
                                                        <t:inputDate id="date" type="full" value="#{pcwBacker.dueDate}" required="true"
                                                                        popupCalendar="true"/>
                                                        <t:message forceSpan="true"  for="date"/>
                                                        <t:commandButton action="#{pcwBacker.enableStepTwo}"
                                                                value="#{pcwBacker.completed ? 'Update' : 'Next Step'}"/>
                                                </t:panelGrid>
                                                </h:form>
                                        </t:panelTab>
                                        <t:panelTab rendered="#{pcwBacker.stepTwoEnabled}" label="People Involved">
                                                <h:form>
                                                <t:panelGrid columns="3">
                                                        <h:outputText value="Leader: "/>
                                                        <h:selectOneMenu id="leader" value="#{pcwBacker.leaderId}" required="true">
                                                                <f:selectItems value="#{pcwBacker.workerItems}"/>
                                                        </h:selectOneMenu>
                                                        <t:message for="leader" forceSpan="true"/>
                                                        <h:outputText value="Assignees: "/>
                                                        <s:selectManyPicklist id="assignees" value="#{pcwBacker.assignees}" size="5">
                                                                <f:selectItems value="#{pcwBacker.workerItems}"/>
                                                        </s:selectManyPicklist>
                                                        <t:message for="assignees" forceSpan="true"/>
                                                        <t:commandButton action="#{pcwBacker.enableStepThree}"
                                                                        value="#{pcwBacker.completed ? 'Update' : 'Next Step'}"/>
                                                        </t:panelGrid>
                                                        </h:form>
                                                </t:panelTab>
                                                <t:panelTab rendered="#{pcwBacker.stepThreeEnabled}" label="Project Description">
                                                <h:form>
                                                <t:panelGrid columns="2">
                                                        <t:inputText/>
                                                        <t:commandButton action="#{pcwBacker.enableFinalStep}"
                                                                        value="#{pcwBacker.completed ? 'Update' : 'Next Step'}"/>
                                                </t:panelGrid>
                                                </h:form>
                                        </t:panelTab>
                                        <t:panelTab rendered="#{pcwBacker.finalStepEnabled}" label="Final">
                                                <h:form>
                                                <t:panelGrid columns="2">
                                                        <t:inputText/><t:commandButton/>
                                                </t:panelGrid>
                                                </h:form>
                                        </t:panelTab>
                                </t:panelTabbedPane>
                        </t:div>
                        <t:div styleClass="side">
                                <t:div styleClass="sectionHeader">
                                        <t:outputText value="Summery"/>
                                </t:div>
                                <t:panelGrid columns="2" cellpadding="10px">
                                        <t:outputText value="Name: #{pcwBacker.name}" rendered="#{pcwBacker.name != null}"/>
                                        <t:outputText value="Status: #{pcwBacker.statusDesc}" rendered="#{pcwBacker.status != null}"/>
                                        <t:outputText value="Phase: #{pcwBacker.phaseDesc}" rendered="#{pcwBacker.phase != null}"/>
                                        <t:outputText value="Category: #{pcwBacker.categoryDesc}" rendered="#{pcwBacker.phase != null}"/>
                                        <t:outputText value="Date Due: #{pcwBacker.dueDate}"/>
                                </t:panelGrid>
                                <h:outputText value="Assignees"/>
                                <t:dataList var="assignee" value="#{pcwBacker.assignees}">
                                        <t:htmlTag value="li">
                                                <t:outputText value="#{pcwBacker.names[assignee]}"/>
                                        </t:htmlTag>
                                </t:dataList>
                        </t:div>
                </t:div>
        </f:view>
        </body>
        </html>The main focus: getting the inputDate working, the border around the container stretching, and not have one div fall beneath another or overlap when the window is resized.
    Any help would be endlessly appreciated. Thank you!
    Message was edited by:
    octoberdaniel

    Thank you for the help. I got everything working with:
    body {
    padding: 1em;
    font-family: georgia, times, "times new roman", serif;
    color: #000;
    img {
    border:0px;
    .container {
    width: 1000px;
    margin: 0 auto;
    border: 1px solid #333;
    .banner {
    border-bottom: 1px solid #333;
    .banner h1 {
    margin: 0;
    padding: .5em;
    .side {
    width: 400px;
    float: right;
    padding: 1em;
    overflow: auto;
    height: 400px;
    .sectionHeader {
    text-align: center;
    padding-bottom: 1em;
    .side p {
    margin-top: 0;
    .content {
    position: absolute;
    padding: 1em;
    overflow: auto;
    height: 400px;
    .content h2 {
    margin-top: 0;
    .footer {
    clear: both;
    background-color: #666;
    text-align: center;
    .pageHeader {
    text-align: center;
    padding-top: 1em;
    Forgeting a doctype also messed some stuff up...
    but I am still having trouble with my calander popup... Any idea?
    Message was edited by:
    octoberdaniel

  • Some songs incomplete in Ipod 2gen 4gig, Driving me crazy !!!

    Hi everyone.
    I have an issue with an iPod Nano 2gen 4gigs Pink. Some songs are just incomplete... they just play for around 30 seconds and then stop.
    I have an iPod Touch as well and those same songs from the same itunes play just perfect. What s more is that when connected to iTunes i can play those songs from my iPod library with no problem on my mac, I also tried on other macs.
    So the songs seem to be complete and fully uploaded to the iPod memory, just they won't playback.
    I already did a reset of the iPod and re-uploaded the library to the ipod, and now some songs that weren t playing before now do, but some random other that played before now don't work anymore...
    Can anyone help me with this ? it s driving me crazy, please !

    Hi,
    I am having same issue with Gen 3 Nano, 8 gig, Red. Need help its like half my music. i have learned that on SOME songs you can scan forward past about 30sec and listen to rest of song, but this is not a fix. any ideas?

  • Can you post album straight to facebook? ive been doing one picture at a time, and its driving me crazy

    can you post album straight to facebook? ive been doing one picture at a time, and its driving me crazy, it doesnt do all the picyures then i have to redo it andits taking hours!!

    You can, open the Photos App, Open the Album you want to upload, and then Tap on the Edit button at the top right corner.
    You can then Tap on the pictures to select them. Once you have all of them selected, tap on the Share button on the top left corner, and then tap on the Facebook icon.  This will upload them all together. 

  • My i tunes won't open. i keep getting error7 (windows error 193) . contacted microsoft(thought it was a windows thing...not) have uninstalled itunes and everything related to it ,re installed and message still comes up. Help please,driving me crazy.

    help. my iTunes wont open. I keep getting the message error7 (windows error 193). contacted Microsoft they said contact iTunes support. I have uninstalled all iTunes componets and then reinstalled everything but message still comes up... its driving me crazy.

    If it's a Windows error, it's typically going to be a Microsoft problem. Uninstall any security software you have and if you have a restore point for your PC, you may want to restore your PC back to when iTunes was working normally. If none of those work you would need to contact Microsoft and demand help.

  • How do I stop iTunes from automatically sorting by Album Artist?  Driving me crazy.

    How do I stop iTunes from automatically sorting by Album Artist?  Driving me crazy.
    I listen to primarily classical music
    All of my music was very deliberatley titled by composers "Last Name, First Name" as the artist.
    iTunes is changing it to the Album Artist.  I have to go in and delete that information - AND THEN IT LATER REVERTS IT BACK!!!
    Hours have been wasted and I am feeling so ticked.
    Any help?

    Purchased or ripped media?
    If these are ripped mp3s then another possibility is multiple embedded tags. iTunes works best with a single ID3v2.3 tag. Some software creates both an ID3v1.0 and IDv2.x tag. With multiple tags it is not certain which iTunes reads or which it updates, and any device may choose differently. Once songs have the correct info. in iTunes you can use Convert ID3 Tags... None several times, then Convert ID3 Tags... v2.3. The process removes any embedded art but otherwise preserves the data that iTunes knows. You could use my script CreateFolderArt before and after to save and then restore the artwork.
    In the long run you may be better off populating Album Artist properly with a copy of whatever is currently in Artist. My script CopyArtistToAlbumArtist can do this effectively.
    tt2

  • I've added to ios6 to my new ipod touch with no problems. I'm trying to now restore the factory settings but the screen is frozen with an itunes sign and lead pointing towards it. The ipod won't even switch off. Can anyone help as it's driving me crazy

    I've added ios6 to my new ipod but tried then to restore the factory settings. It won't extract any settings and the itunes then tells me that the server cannot be reached or is unavailable. I've been trying all day. Now the ipod has a itunes sign and a computer lead pointing towards it on the screen and this is frozen. It won't switch off or do anything else. Any ideas as this is now driving me crazy.

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • I can no longer back up my iphone to my computer on selecting 'sync'. I can back up to iCloud but I get an error message telling me I cannot backup to my Mac. Can any one help? It's driving me crazy!

    I can no longer back up my iphone to my computer on selecting 'sync'. I can back up to iCloud but I get an error message telling me I cannot backup to my Mac. Can any one help? It's driving me crazy!

    Hello joelfromn. charleston,
    It seems you are unable to activate iMessage on a device with no carrier service. The following article provides information regarding activation issues:
    If you get an error when trying to activate iMessage or FaceTime - Apple Support
    Check your device settings
    Make sure that you’re connected to a cellular data or Wi-Fi network. If you're using an iPhone, you'll need SMS messaging to activate your phone number with iMessage and FaceTime. Depending on your carrier, you might be charged for this SMS.
    Go to Settings > General > Date & Time and make sure that your time zone is set up correctly.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    Bobby_D

  • Please help me fix this problem it's driving me crazy. I have tried installing and reinstalling photoshop EXTENDED several time and each time i lunch it ask me for the serial number in which i entered it once entered nothing happens

    Please help me fix this problem it's driving me crazy. I have tried installing and reinstalling photoshop EXTENDED several time and each time i lunch it ask me for the serial number in which i entered it once entered nothing happens

    Hi Glenn,
    Kindly try out the steps mentioned in the link below and see if you are able to serialize your software.
    Sign in, activation, or connection errors | CS5.5 and later, Acrobat DC
    Try Solution 2: Clean up cached user login information.
    Please share the results after performing the steps.
    Thanks,
    Atul Saini

  • Mail 2.1.3 on Tiger: mutiples of everything is driving me crazy!

    Hi, I recently had to reformat my hard drive and thus have been trying to reinstall all my email accounts (which I had backed up). I am using MAIL 2.1.3.
    I have several questions (this is driving me crazy!!):
    When I imported the archived files, it created new mailboxes but DID NOT reinstall my mail in it's corresponding email account file (i.e: i have an email account for incoming mail with "username", and then far below I have a mailbox (for EACH account, and I have about 7) which contains all my old mail. I can't seem to merge the two.
    When I recreated my useraccounts (most of which are gmail), I followed online instructions and created all my accounts using IMAP, since my first attempt using the POP version of these same accounts would NOT SEND OUT any of my Gmail mail. Now, for EACH ACCOUNT, not only do I have a "regular mailbox", I have the same "imported" from my old version, AND a third folder under "IMAP".... All this is REALLY driving me crazy!!
    All I want to achieve is what i had before : one version of each of my email accounts, including Gmail, that both recieve AND send mail. Nothing more.
    On the my other computer (leopard) Mail configures itself and everything works: it's bliss!!!
    Can anyone help me clear up this mess (also because as a result everything is SLOW!!)
    Infinite thanks,
    Nicaru

    Thanks BDAqua, Unfortunately I did not do a very good job explaining myself.
    I am not trying to sync two computers (Tiger/Leopard). The Leopard comment was just me venting that it was so much a better program than Tiger....
    No, what I want is simply to recreate my Mail Client the way it looked before: with one inbox per username, a single Sent/Draft/Outgoing mailbox and that's all!!
    Instead for each username I have "normal" Inboxes, PLUS imported folders (each with their own Inbox/Sent/Draft mailboxes) PLUS IMAP folders again with their own individual Inbox/Sent/Draft mailboxes). My homepage when I open Mail contains something like 21 folders, whereas I only want the 7 (one per username).
    This whole thing came about because when I tried to import my old mailboxes (pre-formatting my mac) they imported as separate folders whereas I wanted them to merge into their respective accounts.
    The other issue I had (originally) which led to this mess is that none of my Gmail accounts would SEND mail (receiving is Ok) so I followed the online IMAP instructions and this is where I got triplets....
    Gosh, I don't know how else to explain it... If it's still not clear perhaps I should just erase everything and start from scratch??
    Thanks again,
    Nicaru

  • Curve issues driving me crazy!!

    Ok, so I bought my BB Curve in January, and at first I loved it!
    A few days ago though it began going crazy.  Everytime I try to open something I get that annoying clock thing, and then once I finally get the program open, it stays.  This happens during phone calls (so it is rediculous trying to answer and end calls)  writing texts and email - anything.
    Then I added in the battery issue - my phone will die within 6 hours, even if I am not doing anything different.
    And now...the last few nights the screen has gone white with a weird meesage on it (something like APP ERROR I think...)
    I got a new SIM card, and that fixed it for about 6 hours. 
    This is driving me crazy!  i take my battery out so many times during the day it is almost not worth having a phone!
    Please please please help!

    I have the Curve 8130 - my carrier is ATT & for about the last mth it has been sluggish. The hourglass keeps popping up like something is running in the background. I have not loaded any new apps recently & it does starighten out after I pop the battery, but that's getting old pretty quick. Fortunately, I'm not having battery issues - but it is a nuisance to keep fighting with that **bleep** hourglass. Anybody else out there having the same issues or are we just the lucky ones???
    Looks like 2 different carriers here, so I don't think it's an ATT thing. Is Blackberry doing something or upgrading something that maybe we're not aware of? I never had an issue with my Curve before - but this last month has been really aggravating. I'm sure we can't be the only 2 people having these issues. Help!!!

  • Auto Sync driving me crazy!

    Hi can anyone help me.
    Im using LR CC and when i select 2 or more images in develop module and make changes (when auto sync is selected) only my visible image changes (not all selected images).
    what am I doing wrong? its driving me crazy!!
    any advice appreciated
    Andrew

    Never heard of such a thing - are you sure auto-sync is enabled in develop module?
    Note: Develop module and Library module both have a separate auto-sync control (i.e. one can be enabled and the other disabled).
    Are you saying that the other images are not appearing changed (previews in filmstrip not being updated), or their settings are not being changed (develop settings unaltered).

  • Sound Effects Driving Me Crazy

    I went to user preferences -> sounds -> and unchecked "play user sound effects" and unchecked "play front row sound effects".
    Yet the sound effects for opening new web pages, clicking on the menu bar, etc keep happening.
    They are driving me crazy. How do I make them stop?
    - Terribly Vexed.

    There may be two things to try. 1: update Mac OS X to v. 10.5.4. this may help. The second option is to simply mute the volume. Hope it works!

  • Motorola Citrus driving me crazy!

    This phone will NOT capitalize the letter "I" automatically.  I am using the multi-touch keyboard ---- auto-correct errors is enabled.  I also added "I" to my dictionary.  How can I fix this?  It is driving me CRAZY!
    Thanks,
    Dana

        Good afternoon danasuemc.
    It sounds like you've done almost everything to get the "I" corrected on your phone. I'd be frustrated as well. Let's see if we can get this permanently fixed.
    Using the Multi-Touch keyboard, do you have Auto-Capitalization and Auto-Punctuate checked? So make sure, you can go to Menu> Settings> Language & Keyboard> Multi-touch Keyboard> then check Auto-Capitalization and Auto-Punctuate. Please let me know if this works.
    Thanks,
    VanessaS_VZWSupport
    Follow us on Twitter @VZWSupport

  • System message driving me crazy:-/

    This system message shows about 30 times a day! It's driving me crazy!! :-/ Please help!!
    process.com.sonyericsson.extras.liveware.extension.online process has stopped.

    Hi
    Samuel provided the best option , and since you've update to lollipop recently , a repair would be helpfull not only in removing these glitches, it would further enhance performance and experience.
    If you don't really want to repair, then you could just try 1-2 things and see if it helps a little bit.
    Go to settings > apps > all > smart connect > clear data .
    Then uninstall updates, and update the app through Play store again. Or simply disable it if you don't use it.
     

Maybe you are looking for

  • SSO from non-SAP to SAP apps

    Hi All, Currently We have SAP applications, non-SAP applications(java, .NET, PHP etc) in our landscape. If the client tries to access any non-SAP application it should ask for authentication and thereby for any subsequent access to any URL's(SAP or N

  • IC WebClient authorizations

    hello Gurus, i searched the forum but couldnt find something useful for my case. I need to know which authorizations i can add a user so the Interaction Center Webclient starts with the complete menu. In my case, when i give the user one Basis Role(w

  • Images missing GPS info in photo library

    hey everyone, I've been using iPhone taking picture and screenshot, import images from other app like GoPro App, wechat, etc, I'm pretty sure before not only the photo taken by iPhone build-in camera has the GPS info, the rest image also has that GPS

  • PC to Mac - file links

    I am switching from PC to Mac - my file links that are stored on a network server do not work any longer - is there a fix for this?

  • X pro crashes when multiple documents are opened

    x pro crashes when multiple documents are opened