You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by WarnerJan Veldhuis <wa...@qprcostcontrol.com> on 2009/10/01 14:19:49 UTC
Streaming to a page
Hello list,
I have an ImagePage class which serves images from a database. All is
working fine, except that I have to have an empty image.htm in order for
the URL to be recognized. Since it serves images, I don't need the .htm
for any html output. Can I somehow leave out the image.htm and only
keep the ImagePage class?
Cheers,
WarnerJan
Re: HibernateForm
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
HibernateForm should apply the requirement constraints all long as those
constraints are specified in Hibernate mappings. So you should have the
following mapping:
<property name="firstName" not-null="true"/>
If you do specify the not-null constraint and HibernateForm does not set
the Field to required, then that looks like a bug in HibernateForm.
kind regards
bob
c-bryu@hitachijoho.com wrote:
> Hi, bob
> Thank you for your response.
>
> The HibernateFrom API has wrote "This form will automatically apply the given objects property required validation constraints to the form fields."
> And the given example is "form.add(new TextField("firstName");"
> The required flag don't set explicitly.
> Maybe change " form.add(new TextField("firstName", true);" to
> " form.add(new TextField("firstName");" , will it work?
> Now I'm in company, I can't test.
>
> Best regards.
> Wateray from Tokyo.
>
> -----Original Message-----
> From: Bob Schellink [mailto:sabob1@gmail.com]
> Sent: Monday, October 05, 2009 10:12 AM
> To: click-user@incubator.apache.org
> Subject: Re: HibernateForm
>
> Hi,
>
> The idea behind HibernateForm is to automate some common functionality
> such as validation. In this case HibernateForm will automatically set
> the field readonly value based on whether the database column allow a
> null value or not. I guess HibernateForm is overriding the value you set
> explicitly.
>
> Perhaps HibernateForm should only set the Field readonly flag if the
> value is false?
>
> kind regards
>
> bob
>
> c-bryu@hitachijoho.com wrote:
>> Hello List
>> When I use HibernateForm, I find something is not correct.
>> Eg. TextField name = new TextField("name", "name", true);
>> The required flag doesn't work.
>> And form.isValid() don't validate.
>> Is this a bug?
>>
>>
>>
>
>
RE: HibernateForm
Posted by c-...@hitachijoho.com.
Hi, bob
Thank you for your response.
The HibernateFrom API has wrote "This form will automatically apply the given objects property required validation constraints to the form fields."
And the given example is "form.add(new TextField("firstName");"
The required flag don't set explicitly.
Maybe change " form.add(new TextField("firstName", true);" to
" form.add(new TextField("firstName");" , will it work?
Now I'm in company, I can't test.
Best regards.
Wateray from Tokyo.
-----Original Message-----
From: Bob Schellink [mailto:sabob1@gmail.com]
Sent: Monday, October 05, 2009 10:12 AM
To: click-user@incubator.apache.org
Subject: Re: HibernateForm
Hi,
The idea behind HibernateForm is to automate some common functionality
such as validation. In this case HibernateForm will automatically set
the field readonly value based on whether the database column allow a
null value or not. I guess HibernateForm is overriding the value you set
explicitly.
Perhaps HibernateForm should only set the Field readonly flag if the
value is false?
kind regards
bob
c-bryu@hitachijoho.com wrote:
> Hello List
> When I use HibernateForm, I find something is not correct.
> Eg. TextField name = new TextField("name", "name", true);
> The required flag doesn't work.
> And form.isValid() don't validate.
> Is this a bug?
>
>
>
Re: HibernateForm
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
The idea behind HibernateForm is to automate some common functionality
such as validation. In this case HibernateForm will automatically set
the field readonly value based on whether the database column allow a
null value or not. I guess HibernateForm is overriding the value you set
explicitly.
Perhaps HibernateForm should only set the Field readonly flag if the
value is false?
kind regards
bob
c-bryu@hitachijoho.com wrote:
> Hello List
> When I use HibernateForm, I find something is not correct.
> Eg. TextField name = new TextField("name", "name", true);
> The required flag doesn't work.
> And form.isValid() don't validate.
> Is this a bug?
>
>
>
HibernateForm
Posted by c-...@hitachijoho.com.
Hello List
When I use HibernateForm, I find something is not correct.
Eg. TextField name = new TextField("name", "name", true);
The required flag doesn't work.
And form.isValid() don't validate.
Is this a bug?
Re: Streaming to a page
Posted by Bob Schellink <sa...@gmail.com>.
You can but will have to specify the Page to Template mapping yourself:
<pages package="org.apache.click.examples.page">
<page path="notemplate.htm" classname="NoTemplate"/>
</pages>
The NoTemplate page does not need to have an associated template since
Click knows that the URL path "notemplate.htm" maps to NoTemplate Page.
Note that the template and Page class does not have to be the same when
performing manually mapping. The following will also work:
<pages package="org.apache.click.examples.page">
<page path="image.htm" classname="NoTemplate"/>
</pages>
Here Click will map the URL path "image.htm" to NoTemplate Page.
However you need to make sure that the NoTemplate Page overrides getPath
and return null:
public class NoTemplate extends BorderPage {
public void onInit() {
try {
// Write directly to the response writer or outputstream
getContext().getResponse().getWriter().print("Hello world");
} catch (IOException ex) {
}
}
public String getPath() {
return null; // <-- Return null
}
}
(Actually getPath can return a value as long as the template it returns
exists so Velocity can render it)
kind regards
bob
WarnerJan Veldhuis wrote:
> Hello list,
>
> I have an ImagePage class which serves images from a database. All is
> working fine, except that I have to have an empty image.htm in order for
> the URL to be recognized. Since it serves images, I don't need the .htm
> for any html output. Can I somehow leave out the image.htm and only
> keep the ImagePage class?
>
> Cheers,
>
> WarnerJan
>