You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by zack1403 <za...@gmail.com> on 2008/05/02 20:05:04 UTC

onValidate NPE

hey all, i am trying to use the onValidate method to verify an uploaded file
but am getting an npe on the UploadedFile.  

Even just trying to record error on form period does nothing as well.  Am I
using the onValidate/recordError incorrectly?  

@Component
private Form form;
private UploadedFile up;

public void onValidate() {
    // form.recordError("an error");
    if(!web.getFileName().endsWith(".ssi")) {
           form.recordError("wrong ext error");
    }

}
-- 
View this message in context: http://www.nabble.com/onValidate-NPE-tp17024869p17024869.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: onValidate NPE

Posted by zack1403 <za...@gmail.com>.
Actually client-side validation works for me with files.  I am testing if the
file is of a certain extension so I always make sure I am uploading files. 
I guess Ill pull down the source and debug it.

Thanks for the help.

Zack


Hmm... are you testing not uploading a file? because if there is no
file uploaded then the UploadFile object will be null. You should make
sure you handle that case because I don't believe the javascript
validation will work on a file upload field.

You might want to grab the source for the upload component and step
through the processSubmission method.

Josh

On Fri, May 2, 2008 at 11:32 AM, zack1403 <za...@gmail.com> wrote:
>
>
>
> Your example is very incomplete and thus hard to debug. What version
> of tapestry are you using?
>
> I'm guessing that the "web" in your method is supposed to be "up"? Do
> you have proper getter/setter methods for your uploadfile?
>
> Josh

-- 
View this message in context: http://www.nabble.com/onValidate-NPE-tp17024869p17027833.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: onValidate NPE

Posted by Josh Canfield <jo...@thedailytube.com>.
Hmm... are you testing not uploading a file? because if there is no
file uploaded then the UploadFile object will be null. You should make
sure you handle that case because I don't believe the javascript
validation will work on a file upload field.

You might want to grab the source for the upload component and step
through the processSubmission method.

Josh

On Fri, May 2, 2008 at 11:32 AM, zack1403 <za...@gmail.com> wrote:
>
>
>
> Your example is very incomplete and thus hard to debug. What version
> of tapestry are you using?
>
> I'm guessing that the "web" in your method is supposed to be "up"? Do
> you have proper getter/setter methods for your uploadfile?
>
> Josh
>
> On Fri, May 2, 2008 at 11:05 AM, zack1403 <za...@gmail.com> wrote:
> >
> > hey all, i am trying to use the onValidate method to verify an uploaded
> > file
> > but am getting an npe on the UploadedFile.
> >
> > Even just trying to record error on form period does nothing as well.  Am
> > I
> > using the onValidate/recordError incorrectly?
> >
> > @Component
> > private Form form;
> > private UploadedFile up;
>
> Sorry about that.  My form works fine outside of any validation so I assumed
> getters/setters were given.  Yes, web==up :/.  No getters/setters for form
> though (I have tried that though).  The files can be saved and modified in
> the onSuccess method just fine.  I no other components in the page.
>
> My tml basically consists of:
>
> <form t:type="form" t:id="form">
> <div class="t-beaneditor-row">
>                                <label t:type="label" for="up" />
>                                <input t:type="upload" t:id="up" validate="required"/>
>                        </div>
>
>                        <div class="t-beaneditor-row">
>                                <input t:type="submit" value="Add" />
>                        </div>
> </form>
>
> By the way, thank you for the quick response!
> --
> View this message in context: http://www.nabble.com/onValidate-NPE-tp17024869p17025322.html
>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: onValidate NPE

Posted by zack1403 <za...@gmail.com>.


Your example is very incomplete and thus hard to debug. What version
of tapestry are you using?

I'm guessing that the "web" in your method is supposed to be "up"? Do
you have proper getter/setter methods for your uploadfile?

Josh

On Fri, May 2, 2008 at 11:05 AM, zack1403 <za...@gmail.com> wrote:
>
> hey all, i am trying to use the onValidate method to verify an uploaded
> file
> but am getting an npe on the UploadedFile.
>
> Even just trying to record error on form period does nothing as well.  Am
> I
> using the onValidate/recordError incorrectly?
>
> @Component
> private Form form;
> private UploadedFile up;

Sorry about that.  My form works fine outside of any validation so I assumed
getters/setters were given.  Yes, web==up :/.  No getters/setters for form
though (I have tried that though).  The files can be saved and modified in
the onSuccess method just fine.  I no other components in the page.
  
My tml basically consists of: 

<form t:type="form" t:id="form">
<div class="t-beaneditor-row">
				<label t:type="label" for="up" />
				<input t:type="upload" t:id="up" validate="required"/>
			</div>
			
			<div class="t-beaneditor-row">
				<input t:type="submit" value="Add" />
			</div>
</form>

By the way, thank you for the quick response!
-- 
View this message in context: http://www.nabble.com/onValidate-NPE-tp17024869p17025322.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: onValidate NPE

Posted by Josh Canfield <jo...@thedailytube.com>.
Your example is very incomplete and thus hard to debug. What version
of tapestry are you using?

I'm guessing that the "web" in your method is supposed to be "up"? Do
you have proper getter/setter methods for your uploadfile?

Josh

On Fri, May 2, 2008 at 11:05 AM, zack1403 <za...@gmail.com> wrote:
>
> hey all, i am trying to use the onValidate method to verify an uploaded file
> but am getting an npe on the UploadedFile.
>
> Even just trying to record error on form period does nothing as well.  Am I
> using the onValidate/recordError incorrectly?
>
> @Component
> private Form form;
> private UploadedFile up;
>
> public void onValidate() {
>    // form.recordError("an error");
>    if(!web.getFileName().endsWith(".ssi")) {
>           form.recordError("wrong ext error");
>    }
>
> }
> --
> View this message in context: http://www.nabble.com/onValidate-NPE-tp17024869p17024869.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org