• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FileUpload Component Query
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FileUpload Component Query


  • Subject: Re: FileUpload Component Query
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 13 Jan 2003 19:28:03 -0800

Hi,

At 03:20 PM 13/01/2003 +0000, Jonathan Fleming wrote:
>Hello Chuck,
>Thanks for you help and advice so far. OK if I use some thing like:
>
>protected String myFilePath;
>
>public void setMyFilePath(String aFilePath) {
>   myFilePath = NSPathUtilities.lastPathComponent(aFilePath);
>}
>
>public String getMyFilePath() {
>   return myFilePath;
>}
>
You will also need something to hold the contents of the file, not just
it's name:
protected NSData uploadedData;

public void setUploadedData(NSData newData) {
   uploadedData = newData;
}

public NSData uploadedData() {
  return uploadedData;
}

This gets bound to the WOFileUpload component.


>How would I then get this into the database if my EOCustomObject java file
>fields are:
>
>public NSData picThumbnail() {
>        return (NSData)storedValueForKey("picThumbnail");
>    }
>
>    public void setPicThumbnail(NSData value) {
>        takeStoredValueForKey(value, "picThumbnail");
>    }
>
This is the uploaded file?


>    public String picThumbRef() {
>        return (String)storedValueForKey("picThumbRef");
>    }
>
>    public void setPicThumbRef(String value) {
>        takeStoredValueForKey(value, "picThumbRef");
>    }
>
This is the name of the uploaded file?


>Can you send example code please, explaination sometimes baffle me, I learn
>best by seeing the physical code
>
If the answer to my questions above are "yes", then you could make an
action method like this:

public WOComponent saveChanges()
{
    if (getMyFilePath() != null)
    {
        // Something was uploaded, update the EO
        eo.setPicThumbRef(getMyFilePath());
        eo.setPicThumbnail(uploadedData());
    }

    // I don't know what page you show next.  This just refreshes this page.
    return context().page();
}


HTH
Chuck


>>From: Chuck Hill <email@hidden>
>>To: Jonathan Fleming <email@hidden>
>>CC: email@hidden
>>Subject: Re: FileUpload Component Query
>>Date: Fri, 10 Jan 2003 15:31:40 -0800
>>
>>Don't bind a WOFileUpload directly to the EO.  Bind it to a String (path)
>>and NSData (file contents) in your component.  Check if the path is
>>non-null.  If it is then something was uploaded and you should update the
>>EO.  Otherwise the user did not select a file.
>>
>>
>>Chuck
>>
>>Jonathan Fleming wrote:
>>
>>>When using a fileUpload component in a form with other elements, I notice
>>>that if I want to edit and update an object I have to choose the required
>>>filePath everytime I do so because if I don't actually enter any data into
>>>the fileupload element I find that on a save to the database I loose what
>>>was originally there. In effect my save has uploaded an empy string.
>>>        When I go to edit an object all the other elements fill themselves
>>>with the exsisting data from the database of that particular row except
>>>the fileupload element which is always empty... how do I get around this
>>>problem of having to enter the same data every time I want to update for
>>>example a spelling mistake in a lastName field, but whish the rest of the
>>>field to stay as they are including the fileUpload field which does not
>>>actually show me what it has entered in it's field.
>>>
>>>        Kind regards
>>>        Jonathan
>>>
>>>        ps Advanced thanks in case I don't get back to you should you
>>>provide the answer.
>>>
>>>
>>>
>>>_________________________________________________________________
>>>The new MSN 8: smart spam protection and 2 months FREE*
>>>http://join.msn.com/?page=features/junkmail
>>>_______________________________________________
>>>webobjects-dev mailing list | email@hidden
>>>Help/Unsubscribe/Archives:
>>>http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>>>Do not post admin requests to the list. They will be ignored.
>>
>>
>>--
>>
>>Chuck Hill  -  Village Idiot               email@hidden
>>Global Village Consulting Inc.             http://www.global-village.net
>
>
>_________________________________________________________________
>MSN 8 with e-mail virus protection service: 2 months FREE*
>http://join.msn.com/?page=features/virus
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: FileUpload Component Query (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: Re: illegal argument error
  • Next by Date: xactisolevel not recognized
  • Previous by thread: Re: FileUpload Component Query
  • Next by thread: PBUserInfo Question
  • Index(es):
    • Date
    • Thread