Menu

Upload question

Help
2010-05-11
2013-04-29
  • jkoulwebster

    jkoulwebster - 2010-05-11

    Hi All:
        I have followed the official manual to write my own upload class,but for some reason it does not  work,who can help me?
        MyUpload.java
       

        @ViewClass(layout = "screen://body")
    public  class MyUpload   {
        @ViewField(label="你的照片",render="upload")
        private Stream stream;
        public void onStream() throws IOException { 
            stream.load();
            OutputStream out = new FileOutputStream("lincolisa.png");
            out.write(stream .getBuffer());
            out.close();
        } 
    }
    

    and I wanna use it in my HomePage, code segment is below

    @ViewField(label = "",  layout="form://upload", render = ViewConstants.RENDER_UPLOAD)
         private MyUpload myUpload=new MyUpload();
    
        public MyUpload getMyUpload() {
                return myUpload;
            }
    

    when I run it,the exception is

    Error on setting value 'org.romaframework.core.domain.type.Stream@158c3b7' for field 'myUpload' on object com.longtop.channel.blog.view.domain.HomePage@1c8ad52
    

    Thanks

    JK.WST

     
  • Nobody/Anonymous

    Hi
    the field myUpload in your HomePage should be rendered as objectembedded ( ViewConstants.RENDER_OBJECTEMBEDDED); moreover, the stream field in MyUpload class should have the getter method.

    Bye,
    Marco

     
  • jkoulwebster

    jkoulwebster - 2010-05-11

    Thanks,it is ok!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.