Streaming to a page

6 messages Options
Embed this post
Permalink
WarnerJan Veldhuis

Streaming to a page

Reply Threaded More More options
Print post
Permalink
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
Bob Schellink-2

Re: Streaming to a page

Reply Threaded More More options
Print post
Permalink
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
>

c-bryu

HibernateForm

Reply Threaded More More options
Print post
Permalink
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?
 
 
Bob Schellink-2

Re: HibernateForm

Reply Threaded More More options
Print post
Permalink
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

[hidden email] 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?
>  
>  
>

c-bryu

RE: HibernateForm

Reply Threaded More More options
Print post
Permalink
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:[hidden email]]
Sent: Monday, October 05, 2009 10:12 AM
To: [hidden email]
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

[hidden email] 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?
>  
>  
>

Bob Schellink-2

Re: HibernateForm

Reply Threaded More More options
Print post
Permalink
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

[hidden email] 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:[hidden email]]
> Sent: Monday, October 05, 2009 10:12 AM
> To: [hidden email]
> 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
>
> [hidden email] 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?
>>  
>>  
>>
>
>