You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Bob Schellink <sa...@gmail.com> on 2010/09/03 13:42:59 UTC

Ajax documentation complete - feedback needed

Hi all,

There is now a chapter covering the new Ajax support[1] and a section
on Page actions[2].

Let me know if there are areas that aren't covered or needs to be expanded upon.

Kind regards

Bob

[1]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html
[2]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html

Re: Ajax documentation complete - feedback needed

Posted by Bob Schellink <sa...@gmail.com>.
Hi Hantsy,

PageActions are indeed action based, but the new Behavior interface is
targeted at Controls allowing one to build Ajax aware controls. For
example, the AutoCompleteTextField uses an internal Behavior to
enhance the Field with Ajax callback support.

The click-jquery[1] project enhances Clicks Ajax support by
integrating jquery taconite[2], providing multiple DOM update support.

Why don't we build our own JS lib? Because I think its largely
unnecessary. Unlike Wicket, Click is stateless with predictable and
bookmarkable URLs. So its easy to integrate with well established JS
libs (jQuery, Prototype et al.) without reinventing the wheel. Again
see click-jquery[1] which integrates with a wide array of jQuery
plugins including jQuery Form and JSTree.

I would also like Click core to stay independent of a specific JS
library implementation.

Kind regards

Bob

[1]: http://code.google.com/p/click-jquery/
[2]: http://jquery.malsup.com/taconite/


On Sat, Sep 4, 2010 at 11:14 AM, Hantsy Bai <ha...@gmail.com> wrote:
>  Hi,
>
>
> I am confused about the Ajax support in Click framewrok.
>
> Click as a component based web framework, but the ajax support is like the
> traditional action based framework(such as struts1/2.x).
>
> 1. why ajax update are not base on Control, like Wicket/JSF2, such as click
> a button, rerender one Control in current page or replace it with other
> Control or append a Control to some specified Control, this is the nature
> way in a component based framework.
>
> 2. Provide Seam like remote js library, make js client use Click Control
> directly in javascript.
>
>
> Regards
>
> Hantsy
>
> 于 2010/9/4 1:37, Beto 写道:
>>
>> Bob,
>>
>> Just a little correction
>>
>> (https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s02.html)
>> Last item should be:
>>
>> setContentType(String) - set the ActionResult content type, for
>> example: text/html, text/xml, application/json etc.
>>
>> instead of:
>>
>> setModel(Map) - set the ActionResult content type, for example:
>> text/html, text/xml, application/json etc.
>>
>> Regards,
>>
>> Gilberto
>>
>> On Fri, Sep 3, 2010 at 8:42 AM, Bob Schellink<sa...@gmail.com>  wrote:
>>>
>>> Hi all,
>>>
>>> There is now a chapter covering the new Ajax support[1] and a section
>>> on Page actions[2].
>>>
>>> Let me know if there are areas that aren't covered or needs to be
>>> expanded upon.
>>>
>>> Kind regards
>>>
>>> Bob
>>>
>>>
>>> [1]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html
>>>
>>> [2]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html
>>>
>
>

Re: Ajax documentation complete - feedback needed

Posted by Bob Schellink <sa...@gmail.com>.
On Mon, Sep 6, 2010 at 7:46 PM, Andrew Fink <ap...@gmail.com> wrote:
>
> I agree with:
> - auto generated ID (like Field's do)
>
> - auto-add this ID to link if behaviors list isn't empty or

What if that link is repeated, as often happens with Table action
columns? You'll end up with duplicate IDs.

Regardless I don't think the controls need to change. rather the
Behavior implementation could generate a unique ID. Personally I think
setting the ID explicitly isn't a big deal unless you build large Ajax
rich pages containing many controls.

Kind regards

Bob

Re: Ajax documentation complete - feedback needed

Posted by Andrew Fink <ap...@gmail.com>.
I agree with:
- auto generated ID (like Field's do)

- auto-add this ID to link if behaviors list isn't empty or
setIncludeId(true) called
These both can eliminate low-level work with id.
-- 
View this message in context: http://click.1134972.n2.nabble.com/Ajax-documentation-complete-feedback-needed-tp5495025p5502637.html
Sent from the click-user mailing list archive at Nabble.com.

Re: Ajax documentation complete - feedback needed

Posted by Andrei Ionescu <ai...@yahoo.com>.
>> I understand that Ajax is not that easy, so maybe it's impossible with Click
>> to offer the same level of "magic" like it usually does.
>
> Not sure where you see "magic" but one of the things that attracted me
> to Click is that there was no magic. It is stateless, URLs are
> predictable and it follows the DRY principle.
I mean by magic: Automapping, Autobinding, very good defaults for many
components, that they have predictable and easy to learn API, the nice 
toString(onRender) so that templates remain extremely small, and sure, 
the fact that it's totally customizable if needed (but I haven't use 
this - I guess it's more as an insurance for the management :) )

>> Unfortunately, for me this "Behavior" functionality doesn't sounds "too
>> natural". It also feels just too much like Wicket.
>
> I think we need to be careful of trying to be different just for the
> sake of it. This is open source after all, and we should borrow good
> ideas from other frameworks.
Sure, but only the idea :). I was just trying say that their approach to 
problems(from the user's standpoint, as what he needs to do to achieve a 
task) is not simple at all, even if that slogan is overused.
I can't even use that word anymore with Click cause it's automatically
associated with them :(.

> Not saying Behavior is good but I do
> think it accurately describes the feature.
Well, even if others already use that name, the naming still makes me 
associate with
so other concepts :). I have no idea what other name would suitable: 
"Transformer", "Changer", "Morpher" ?

> Is it the Behavior concept that you find difficult or is it the
> implementation that is complex?
I can't say much about the implementation yet, but so far I find quite 
allot of what the user must code to achieve a simple result (compared to 
the usual stuff in Click):
https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s04.html

I understand that Click wants to remain JS framework independent, but
maybe some simple helper JS or shortcuts wouldn't be so bad - even if 
they're in click-examples only so that users can copy and paste them (s 
they already do with most of the stuff from click-examples :) ).

For the example from ch 4.4:
  --> 1. would be easier if Click would simply provide his unique 
default ID like it usually does for components. I think there would be 
no need for the user to specify or care about it, only in exceptional 
cases. This could also propagate to the template too, so that the user 
doesn't code it over and over again.
  --> 2. "<div id="result">" - for most cases would be interesting if 
this placeholder could be also generated by Click too, since the Page 
already knows that it's Ajax in there.
  --> 3. In ajax-behavior.htm, I suppose something like makeRequest will 
be called most of the time, so maybe some generic helpers would be 
practical - for the case the user doesn't need the full blown 
click-jquery or other click-xxxx libraries.

What I mean with all this stuff (from the user's view), is that it would 
be cool if Click like usually does, would do everything behind the 
scenes for 80% of the cases and the user would only need to do maybe the 
following or less:
--------------------
public class AjaxBehaviorPage extends BorderPage {
   public ActionLink link = new ActionLink("link", "here");
   public DivPanel result = new DivPanel();
   public AjaxBehaviorPage() {
     link.addBehavior("onAjaxAction", this);
     addJS(JQUERY, "customScript", this, result);//magic with 
getHeadElemnts with jQuery.
     }
     public ActionResult onAjaxAction(Control source){
       return new ActionResult("......", HTML);
     }
     public void customScript(ActionResult data, Control result){
       result.setContent(data.getContent());
     }
--------------------

so ajax-behavior.htm could look like:
--------------------
Click $link to call the server using Ajax.
$result
--------------------

> I assume you have looked at the
> Behavior Javadoc? Perhaps it needs further explaining or more
> examples?
Yes. For some of the new classes the Javadoc is not much, but for other
it's quite allot :). More examples? yes, but I'm not sure about the 
explanations.

>> Regarding the documentation:
>>
>>   4. "...Note, if you want to send a specific response to the client or
>> perform a redirect you have to do that from the onSecurityCheck() event,
>> since other Page events are not processed."
>>     --->  Is there an example how to send a specific response from
>> onSecurityCheck? since it's not returning an ActionResponse to be able to
>> returns something to the client.
>
> I'll add an example, but essentially you'll have to render directly to
> the HttpResponse. Normally one would redirect to another page, but
> redirect is not supported directly by Ajax.
>> Other questions to chapter 2.7:
>>   5. can the pageAction parameter be configured/renamed by the user or is it
>> hardcoded in Click?
>
> I guess one could create a custom ClickServlet to change it...
I'm asking since in some applications this parameter can be "reserved" 
and need for other things: it's so general (it's not in the Click 
namespace). Other applications could need it because of
legacy, when migrating from another framework to Click (e.g. just had a 
small CMS module using it. I'm not allowed to change it cause the 
rewrite rules (that make REST like URLs) are outside of the project.

In fact it would be cool if other Click constant names could be simply 
overridden too.

>> C.
>> https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s04.html
>>   --->  It would be nice if it would be possible to use that example without
>> an anonymous class - the same way it's possible with other listeners. E.g.
>> link.addBehavior("onAjaxAction").
>
> Where "onAjaxAction" is a method on the Page?
Yes, or just like with the buttons or action links, but I forgot the 
target, so: link.addBehavior("onAjaxAction", this). :).

It would be nice if it would be possible to avoid anonymous classes
and have nice "flowing" code in pages :).

regards,
Andrei.




Re: Ajax documentation complete - feedback needed

Posted by Bob Schellink <sa...@gmail.com>.
Hi,

On Sat, Sep 4, 2010 at 11:07 PM, Andrei Ionescu <ai...@yahoo.com> wrote:

> I understand that Ajax is not that easy, so maybe it's impossible with Click
> to offer the same level of "magic" like it usually does.

Not sure where you see "magic" but one of the things that attracted me
to Click is that there was no magic. It is stateless, URLs are
predictable and it follows the DRY principle.

> Unfortunately, for me this "Behavior" functionality doesn't sounds "too
> natural". It also feels just too much like Wicket.

I think we need to be careful of trying to be different just for the
sake of it. This is open source after all, and we should borrow good
ideas from other frameworks. Not saying Behavior is good but I do
think it accurately describes the feature.

> The "Partial" - on the other hand was quite straight forward to understand.

Is it the Behavior concept that you find difficult or is it the
implementation that is complex? I assume you have looked at the
Behavior Javadoc? Perhaps it needs further explaining or more
examples?

The Behavior concept is used by both Wicket and JSF so it is becoming
well known outside of Click. Btw. Partial and Behavior are orthogonal
concepts and not related to each other.

>
> Regarding the documentation:
> A.
> https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html
>   :
>  1. "...template will not be rendered. More on this later."
>    --> The last phrase could be dropped or replaced with a direct link to
> the section that details the subject. This appears in several places in the
> documentation.
>
>  2. "First we create our template:
>     <img src="/mycorp/images.htm?pageAction=onRenderImage"/>
>    "
>    --> shouldn't be "$context/mycorp...." ? Also this refers to the
> corresponding template: image.htm?

Fixed.
>
>  3. ..., a new Page instance is created and the attributes for the Page ..."
>    ---> so each Ajax method call will create a new Page? Isn't this a
> performance problem since Ajax calls are many? Or the page can be stateful
> to reduce object creation?

I think it might be faster as there is no need to synchronize.
>
>  4. "...Note, if you want to send a specific response to the client or
> perform a redirect you have to do that from the onSecurityCheck() event,
> since other Page events are not processed."
>    ---> Is there an example how to send a specific response from
> onSecurityCheck? since it's not returning an ActionResponse to be able to
> returns something to the client.

I'll add an example, but essentially you'll have to render directly to
the HttpResponse. Normally one would redirect to another page, but
redirect is not supported directly by Ajax.

> Other questions to chapter 2.7:
>  5. can the pageAction parameter be configured/renamed by the user or is it
> hardcoded in Click?

I guess one could create a custom ClickServlet to change it...
>
>  6. If the content of the ActionResponse is complicated (but still not a
> complete page), is it possible to have Velocity render it the same way it
> does for a normal page?

Off course. ActionResponse can render any chars or bytes.
>
> B.
> https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html#ajax-overview
>  1. "You can use pure JavaScript or one of the popular JavaScript libraries
> such as: jQuery, Prototype ..."
>    ---> I think here would be a good place to mention Click-JQuery project.
>
> C.
> https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s04.html
>  ---> It would be nice if it would be possible to use that example without
> an anonymous class - the same way it's possible with other listeners. E.g.
> link.addBehavior("onAjaxAction").

Where "onAjaxAction" is a method on the Page?
>
> I'm still trying to understand correctly the rest of Behaviors :), so if
> it's not in "code freeze" I will post later some more feedback.

Go ahead its not in codefreeze. I would however ask that you
differentiate between Behavior as a concept and the implementation.
That would make it easier for us to identify and resolve the problem
areas.

Thanks.

Bob

Re: Ajax documentation complete - feedback needed

Posted by Andrei Ionescu <ai...@yahoo.com>.
Thank you very much for the detailed documentation and the Ajax 
implementation. It's good to see that Click has "default" support for 
Ajax. Even if Ajax was possible before, now, being default, Click won't 
come short when compared to other frameworks.

> I am confused about the Ajax support in Click framework.
Me too :( :

It's important to have this new Ajax support, but to me it looks 
complicated
(at least compared to what I'm used with Click).

I understand that Ajax is not that easy, so maybe it's impossible with 
Click to offer the same level of "magic" like it usually does.
Unfortunately, for me this "Behavior" functionality doesn't sounds "too 
natural". It also feels just too much like Wicket. The "Partial" - on 
the other hand was quite straight forward to understand.

Regarding the documentation:
A. 
https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html 
   :
  1. "...template will not be rendered. More on this later."
     --> The last phrase could be dropped or replaced with a direct link 
to the section that details the subject. This appears in several places 
in the documentation.

  2. "First we create our template:
      <img src="/mycorp/images.htm?pageAction=onRenderImage"/>
     "
     --> shouldn't be "$context/mycorp...." ? Also this refers to the 
corresponding template: image.htm?

  3. ..., a new Page instance is created and the attributes for the Page 
..."
     ---> so each Ajax method call will create a new Page? Isn't this a 
performance problem since Ajax calls are many? Or the page can be 
stateful to reduce object creation?

  4. "...Note, if you want to send a specific response to the client or 
perform a redirect you have to do that from the onSecurityCheck() event, 
since other Page events are not processed."
     ---> Is there an example how to send a specific response from 
onSecurityCheck? since it's not returning an ActionResponse to be able 
to returns something to the client.

Other questions to chapter 2.7:
  5. can the pageAction parameter be configured/renamed by the user or 
is it hardcoded in Click?

  6. If the content of the ActionResponse is complicated (but still not 
a complete page), is it possible to have Velocity render it the same way 
it does for a normal page?

B. 
https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html#ajax-overview
   1. "You can use pure JavaScript or one of the popular JavaScript 
libraries such as: jQuery, Prototype ..."
     ---> I think here would be a good place to mention Click-JQuery 
project.

C. 
https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s04.html
   ---> It would be nice if it would be possible to use that example 
without an anonymous class - the same way it's possible with other 
listeners. E.g. link.addBehavior("onAjaxAction").

I'm still trying to understand correctly the rest of Behaviors :), so if 
it's not in "code freeze" I will post later some more feedback.

regards,
Andrei.


Re: Ajax documentation complete - feedback needed

Posted by Bob Schellink <sa...@gmail.com>.
On Sat, Sep 4, 2010 at 11:14 AM, Hantsy Bai <ha...@gmail.com> wrote:
>
> Click as a component based web framework, but the ajax support is like the
> traditional action based framework(such as struts1/2.x).
>
> 1. why ajax update are not base on Control, like Wicket/JSF2, such as click
> a button, rerender one Control in current page or replace it with other
> Control or append a Control to some specified Control, this is the nature
> way in a component based framework.
>
> 2. Provide Seam like remote js library, make js client use Click Control
> directly in javascript.

If anyone in the Click community wants to write such a library or
provide integration with an existing library trhis is a good place for
that discussion.

Regards,

Bob

Re: Ajax documentation complete - feedback needed

Posted by Hantsy Bai <ha...@gmail.com>.
  Hi,


I am confused about the Ajax support in Click framewrok.

Click as a component based web framework, but the ajax support is like 
the traditional action based framework(such as struts1/2.x).

1. why ajax update are not base on Control, like Wicket/JSF2, such as 
click a button, rerender one Control in current page or replace it with 
other Control or append a Control to some specified Control, this is the 
nature way in a component based framework.

2. Provide Seam like remote js library, make js client use Click Control 
directly in javascript.


Regards

Hantsy

于 2010/9/4 1:37, Beto 写道:
> Bob,
>
> Just a little correction
> (https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s02.html)
> Last item should be:
>
> setContentType(String) - set the ActionResult content type, for
> example: text/html, text/xml, application/json etc.
>
> instead of:
>
> setModel(Map) - set the ActionResult content type, for example:
> text/html, text/xml, application/json etc.
>
> Regards,
>
> Gilberto
>
> On Fri, Sep 3, 2010 at 8:42 AM, Bob Schellink<sa...@gmail.com>  wrote:
>> Hi all,
>>
>> There is now a chapter covering the new Ajax support[1] and a section
>> on Page actions[2].
>>
>> Let me know if there are areas that aren't covered or needs to be expanded upon.
>>
>> Kind regards
>>
>> Bob
>>
>> [1]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html
>> [2]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html
>>


Re: Ajax documentation complete - feedback needed

Posted by Bob Schellink <sa...@gmail.com>.
On Sat, Sep 4, 2010 at 3:37 AM, Beto <gi...@gmail.com> wrote:
> Just a little correction
> (https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s02.html)
> Last item should be:
>
> setContentType(String) - set the ActionResult content type, for
> example: text/html, text/xml, application/json etc.

Thanks Gilberto, should be fixed now.

Bob

Re: Ajax documentation complete - feedback needed

Posted by Beto <gi...@gmail.com>.
Bob,

Just a little correction
(https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04s02.html)
Last item should be:

setContentType(String) - set the ActionResult content type, for
example: text/html, text/xml, application/json etc.

instead of:

setModel(Map) - set the ActionResult content type, for example:
text/html, text/xml, application/json etc.

Regards,

Gilberto

On Fri, Sep 3, 2010 at 8:42 AM, Bob Schellink <sa...@gmail.com> wrote:
> Hi all,
>
> There is now a chapter covering the new Ajax support[1] and a section
> on Page actions[2].
>
> Let me know if there are areas that aren't covered or needs to be expanded upon.
>
> Kind regards
>
> Bob
>
> [1]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch04.html
> [2]:https://hudson.apache.org/hudson/view/Click/job/Click/javadoc/docs/user-guide/html/ch02s07.html
>