You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andre Beskrowni <AB...@axeda.com> on 2002/02/21 21:52:29 UTC

does anyone just read the source code? (WAS Re: tag)

it is free after all...  another good way to try to solve a problem is to
step through the source code in a debugger.  

i realize this list exists to help other and get help from others, but the
amount of time people spend going back and forth saying "nope that doesn't
solve my problem.  i need more help."  is mind boggling when could spend an
hour or two working on the problem on their own and have it solved.  (note:
you'd be amazed how self-sufficient you can become when you dare to look at
the source code.)

as for henry, i don't mean to pick on you, i'm just feeling impatient today.
try using string attributes in your form bean.

ab

> -----Original Message-----
> From: Henry Lu [mailto:zhlu@umich.edu]
> Sent: Thursday, February 21, 2002 3:31 PM
> To: Struts Users Mailing List
> Subject: Re: <html:file> tag
> 
> 
> Thanks Eddie. But it is not detail enough to make it work. 
> Here is my code
> and I got the errors:
> 
> javax.servlet.ServletException: BeanUtils.populate
> ....
> Root Cause:
> java.lang.IllegalArgumentException: argument type mismatch
> 
> ////////////////////////////////////////////////////////////////////
> int the form:
> 
> private FormFile myfile;
> 
> public void setMyfile(FormFile f)
>    myfile = f;
> }
> 
> public FormFile getMyfile()
>    return myfile;
> }
> 
> ///////////////////////////////////////////////////////////////////
> in the jsp file:
> 
> <html:file property="myfile"/>
> 
> ///////////////////////////////////////////////////////////////////
> Why it doesn't work? How to fix?
> 
> 
> --------------------------------------------------------------
> -------------
> Henry Lu
> MCIT                                            phone: (734) 936-2063
> University of Michigan Medical Center           fax:   (734) 763-4372
> 
> On Thu, 21 Feb 2002, Eddie Bush wrote:
> 
> > I'm sorry you comment in validate indicated to me that you 
> were asking about
> > validate.  Try this:
> >
> > 
> http://jakarta.apache.org/struts/userGuide/building_view.html#
> form_input
> >
> > ... scroll up just a tad and you should have what you're 
> looking for.
> >
> >
> > ----- Original Message -----
> > From: "Henry Lu" <zh...@umich.edu>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Thursday, February 21, 2002 1:23 PM
> > Subject: Re: <html:file> tag
> >
> >
> > > Eddie, you are not answering my question at all. My 
> question is how to use
> > > <html:file> tag and retrieve the content of file.
> > >
> > >
> > > 
> --------------------------------------------------------------
> ------------
> > -
> > > Henry Lu
> > > MCIT                                            phone: 
> (734) 936-2063
> > > University of Michigan Medical Center           fax:   
> (734) 763-4372
> > >
> > > On Thu, 21 Feb 2002, Eddie Bush wrote:
> > >
> > > > The validate function can be implemented to validate 
> your form input.
> > If
> > > > you find erros, you can put those errors into an 
> ActionErrors object and
> > > > then return them.  The 'best practice' approach would 
> probably be to
> > have
> > > > your validation encapsulated in a 'utility bean' that you could
> > instantiate
> > > > to make calls against (that's how I am doing mine 
> anyway).  However, for
> > a
> > > > small project you could easily include all of you login right in
> > validate.
> > > > There is a good example of doing this in the struts 
> documentation, and I
> > > > believe the users guide covers the topic quite well 
> too.  If you haven't
> > > > already looked them over, you really should.
> > > >
> > > > How to best use the validation mechanisms provided by 
> struts is quite a
> > > > debated issue =)
> > > >
> > > > No matter where/how you implement your logic to 
> validate your form,
> > you'll
> > > > want to create an ActionErrors instance and add 
> ActionError instances to
> > it,
> > > > and finally return the ActionErrors object.  Very simply:
> > > >
> > > > ActionErrors actionErrors = new ActionErrors();
> > > >
> > > > ... then, assuming they don't specify a file - and 
> assuming it is a
> > required
> > > > field.
> > > >
> > > > actionErrors.add("File", new 
> ActionError("error.file.required"));
> > > >
> > > > and then at the end of your perform, don't forget to:
> > > >
> > > > return actionErrors;
> > > >
> > > > The text passed to the ActionError constructor 
> ("error.file.required")
> > needs
> > > > to be specified in your application resources file.
> > > >
> > > > HTH,
> > > >
> > > > Eddie
> > > >
> > > > ----- Original Message -----
> > > > From: "Henry Lu" <zh...@umich.edu>
> > > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > > Sent: Thursday, February 21, 2002 12:58 PM
> > > > Subject: Re: <html:file> tag
> > > >
> > > >
> > > > > Thanks for your info! But I need a little bit more details:
> > > > >
> > > > > //int my FileForm.java file
> > > > > /////////////////////////////////////////////////////
> > > > > public class FileForm extends ActionForm
> > > > > {
> > > > >    private String theFile;
> > > > >
> > > > >    public FileForm() {}
> > > > >
> > > > >    public void setTheFile(String file)
> > > > >    {
> > > > >       this.theFile = file;
> > > > >    }
> > > > >
> > > > >    public String getTheFile()
> > > > >    {
> > > > >       return this.theFile;
> > > > >    }
> > > > >
> > > > >    ...
> > > > >
> > > > >    public ActionErrors validate(...)
> > > > >    {
> > > > >       ////////////////////////////////////
> > > > >       // what should i do here?
> > > > >    }
> > > > > }
> > > > >
> > > > > //////////////////////////////////////////////////////
> > > > > //int the jsp page:
> > > > > ////////////////////////////////////////////////////////
> > > > > <html:file property="theFile" accept="text" />
> > > > >
> > > > > Could you tell me what exactly to do and where to add code?
> > > > >
> > > > > Thank you very much!
> > > > >
> > > > >
> > > >
> > > 
> --------------------------------------------------------------
> ------------
> > > > -
> > > > > Henry Lu
> > > > > MCIT                                            
> phone: (734) 936-2063
> > > > > University of Michigan Medical Center           fax:  
>  (734) 763-4372
> > > > >
> > > > > On Thu, 21 Feb 2002, SUPRIYA MISRA wrote:
> > > > >
> > > > > > In your validation function first store it.
> > > > > > Stringbuffer filecontent= file content.
> > > > > > request.setAttribute("file",filecontent);
> > > > > > On Jsp use equal tag to see if you have the 
> content--take it else
> > ask
> > > > for a
> > > > > > new one.
> > > > > >
> > > > > >
> > > > > > >From: Henry Lu <zh...@umich.edu>
> > > > > > >Reply-To: "Struts Users Mailing List"
> > <st...@jakarta.apache.org>
> > > > > > >To: struts users <st...@jakarta.apache.org>
> > > > > > >Subject: <html:file> tag
> > > > > > >Date: Thu, 21 Feb 2002 10:48:05 -0500 (EST)
> > > > > > >
> > > > > > >How do i retrieve the content of file in the 
> formAction program?
> > The
> > > > only
> > > > > > >thing I get from the tag is the file name (exa: 
> 1.txt). How do I
> > get
> > > > the
> > > > > > >content of the file?
> > > > > > >
> > > > > > >
> > > > > >
> > > >
> > 
> >-------------------------------------------------------------
> --------------
> > > > > > >Henry Lu
> > > > > > >MCIT                                            
> phone: (734)
> > 936-2063
> > > > > > >University of Michigan Medical Center           
> fax:   (734)
> > 763-4372
> > > > > > >
> > > > > > >
> > > > > > >--
> > > > > > >To unsubscribe, e-mail:
> > > > > > ><ma...@jakarta.apache.org>
> > > > > > >For additional commands, e-mail:
> > > > > > ><ma...@jakarta.apache.org>
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > 
> _________________________________________________________________
> > > > > > Chat with friends online, try MSN Messenger:
> > http://messenger.msn.com
> > > > > >
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:   
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>