You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by "Andrey P.Rybin" <ap...@gmail.com> on 2010/02/04 14:03:53 UTC

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

After some investigation - It isn't off-topic!

It is cool feature.

I will make example in near time:

How to make Click application without javac (and .java files at all)!

Rails and Grails will be dead.

Dynamic Click is coming ;-)



On Wed, Feb 3, 2010 at 21:37, Andrey P.Rybin <ap...@gmail.com> wrote:
> Sorry for off-topic, but I think it can help somebody.
> And I need testers ;-\
>
> I have made bug fixed, improved, multi-thread safe, spring 3.0
> compatible JavaScriptFactory "on steroids".
>
> * https://jira.springsource.org/browse/SPR-1933
> * Direct download:
> https://jira.springsource.org/secure/attachment/16139/org.springframework.scripting.rhino.zip
> * Examples: https://jira.springsource.org/browse/SPR-1933?focusedCommentId=50770&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_50770
>
>
> It is Rhino javascript support for Spring framework (core, not mvc).
> Spring supports out-of-box BeanShell, JRuby and Groovy.
> With JavaScriptFactory you can write your Spring beans in Javascript.
>
>
> Russian announce (with many examples):
> http://community.livejournal.com/ru_java/901310.html
>

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

Posted by "Andrey P.Rybin" <ap...@gmail.com>.
Example (final): How to write Spring-powered Click Pages in javascript?
=====================================================================
(if you don't need Spring you can use javascript more "directly")

1) download JavaScriptFactory sources and build them (or just put in
your project sources)
https://jira.springsource.org/browse/SPR-1933


2) make page htm template as usual (my example JsPage.htm included)


3) put in your source from spring.xml (included).


4) Click hack/workaround:
put empty
public class JsPage extends Page {}
in package from click.xml pages.package


5) write your javascript ;-)
Example script is attached.


6) You can use ClickJsUtils.js for cool autobinding.


I found only two problems:
1) autocomplete doesn't work (IDE doesn't know this kind of DOM model ;-)
but if you are using vim/emacs/etc - it isn't problem for you ;-)

2) damn dynamic languages! You can't be sure, that your code is ok
without 100% unit test code coverage ;-(

Ok!  And that's about all I know about shrimps!

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

Posted by "Andrey P.Rybin" <ap...@gmail.com>.
Ok!

Final, clean example:

*) spring.xml:

  <bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"
/>

  <bean id="jsPage" class="net.sf.apr.spring.JavaScriptFactory"
scope="prototype">
    <constructor-arg index="0" value="classpath:JsPage.js" /><!-- your
page code -->
    <constructor-arg index="1"><null /></constructor-arg>
    <constructor-arg index="2" value="classpath:ClickJsUtils.js"
/><!-- constant click utils -->
  </bean>

*) New JsPage.js and ClickJsUtils.js are attached.

JsPage.js contains only business logic and is very clean.



On Fri, Feb 5, 2010 at 21:56, Andrey P.Rybin <ap...@gmail.com> wrote:
> I have made new JsPage.js version with autobinding ;-)
>
> It looks fresh and nice.
> "Spring powered declarative javascript Click programming" (c) ;-)
>
> Attached file is actually JsPage.js.
>
> On Fri, Feb 5, 2010 at 16:28, Andrey P.Rybin <ap...@gmail.com> wrote:
>> Bob Schellink wrote:
>> does it mean you write your Click page in a dynamic language?
>>
>>
>> Yes! Exactly! But nothing special for Click ;-/
>>
>> I found bug, that prevents using this feature.
>> https://issues.apache.org/jira/browse/CLK-622
>>
>> But I did example with workaround.
>>
>> Example: How to write Spring-powered Click Pages in javascript?
>> ===============================================
>> (if you don't need Spring you can use javascript more "directly")
>>
>> 1) download JavaScriptFactory sources and build them (or just put in
>> your project sources)
>>
>> 2) make page htm template as usual (JsPage.htm in this example)
>>
>> 3) put in your spring.xml:
>>  <!-- enable script beans -->
>>  <bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"
>> />
>>
>>  <!-- id = your page name converted to bean name (1st letter in
>> lowercase), net.sf.apr.spring.JavaScriptFactory - my class, you can
>> put it in your package or  in org.springframework.scripting.rhino
>> package -->
>>  <bean id="jsPage" class="net.sf.apr.spring.JavaScriptFactory"
>> scope="prototype">
>>    <constructor-arg index="0" value="classpath:JsPage.js" /><!-- use
>> this script in WEB-INF/classes/JsPage.js -->
>>    <constructor-arg index="1"><null /></constructor-arg>
>>  </bean>
>>
>> 4) Click hack/workaround:
>> put empty
>> public class JsPage extends Page {}
>> in package from click.xml pages.package
>>
>> 5) write your javascript ;-)
>> Example script is attached.
>>
>> I found two problems:
>> 1) autocomplete doesn't work (IDE doesn't know this kind of DOM model ;-)
>> 2) autobinding doesn't work - hmm... may be put it to JIRA?
>> Click could support not only fields, but getters [public type getField()] too.
>> Because Rhino can generate methods, but can't fields (it is obvious).
>>
>>
>>
>>
>> On Thu, Feb 4, 2010 at 18:03, Andrey P.Rybin <ap...@gmail.com> wrote:
>>> After some investigation - It isn't off-topic!
>>>
>>> It is cool feature.
>>>
>>> I will make example in near time:
>>>
>>> How to make Click application without javac (and .java files at all)!
>>>
>>> Rails and Grails will be dead.
>>>
>>> Dynamic Click is coming ;-)
>>>
>>>
>>>
>>> On Wed, Feb 3, 2010 at 21:37, Andrey P.Rybin <ap...@gmail.com> wrote:
>>>> Sorry for off-topic, but I think it can help somebody.
>>>> And I need testers ;-\
>>>>
>>>> I have made bug fixed, improved, multi-thread safe, spring 3.0
>>>> compatible JavaScriptFactory "on steroids".
>>>>
>>>> * https://jira.springsource.org/browse/SPR-1933
>>>> * Direct download:
>>>> https://jira.springsource.org/secure/attachment/16139/org.springframework.scripting.rhino.zip
>>>> * Examples: https://jira.springsource.org/browse/SPR-1933?focusedCommentId=50770&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_50770
>>>>
>>>>
>>>> It is Rhino javascript support for Spring framework (core, not mvc).
>>>> Spring supports out-of-box BeanShell, JRuby and Groovy.
>>>> With JavaScriptFactory you can write your Spring beans in Javascript.
>>>>
>>>>
>>>> Russian announce (with many examples):
>>>> http://community.livejournal.com/ru_java/901310.html
>>>>
>>>
>>
>

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

Posted by "Andrey P.Rybin" <ap...@gmail.com>.
I have made new JsPage.js version with autobinding ;-)

It looks fresh and nice.
"Spring powered declarative javascript Click programming" (c) ;-)

Attached file is actually JsPage.js.

On Fri, Feb 5, 2010 at 16:28, Andrey P.Rybin <ap...@gmail.com> wrote:
> Bob Schellink wrote:
> does it mean you write your Click page in a dynamic language?
>
>
> Yes! Exactly! But nothing special for Click ;-/
>
> I found bug, that prevents using this feature.
> https://issues.apache.org/jira/browse/CLK-622
>
> But I did example with workaround.
>
> Example: How to write Spring-powered Click Pages in javascript?
> ===============================================
> (if you don't need Spring you can use javascript more "directly")
>
> 1) download JavaScriptFactory sources and build them (or just put in
> your project sources)
>
> 2) make page htm template as usual (JsPage.htm in this example)
>
> 3) put in your spring.xml:
>  <!-- enable script beans -->
>  <bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"
> />
>
>  <!-- id = your page name converted to bean name (1st letter in
> lowercase), net.sf.apr.spring.JavaScriptFactory - my class, you can
> put it in your package or  in org.springframework.scripting.rhino
> package -->
>  <bean id="jsPage" class="net.sf.apr.spring.JavaScriptFactory"
> scope="prototype">
>    <constructor-arg index="0" value="classpath:JsPage.js" /><!-- use
> this script in WEB-INF/classes/JsPage.js -->
>    <constructor-arg index="1"><null /></constructor-arg>
>  </bean>
>
> 4) Click hack/workaround:
> put empty
> public class JsPage extends Page {}
> in package from click.xml pages.package
>
> 5) write your javascript ;-)
> Example script is attached.
>
> I found two problems:
> 1) autocomplete doesn't work (IDE doesn't know this kind of DOM model ;-)
> 2) autobinding doesn't work - hmm... may be put it to JIRA?
> Click could support not only fields, but getters [public type getField()] too.
> Because Rhino can generate methods, but can't fields (it is obvious).
>
>
>
>
> On Thu, Feb 4, 2010 at 18:03, Andrey P.Rybin <ap...@gmail.com> wrote:
>> After some investigation - It isn't off-topic!
>>
>> It is cool feature.
>>
>> I will make example in near time:
>>
>> How to make Click application without javac (and .java files at all)!
>>
>> Rails and Grails will be dead.
>>
>> Dynamic Click is coming ;-)
>>
>>
>>
>> On Wed, Feb 3, 2010 at 21:37, Andrey P.Rybin <ap...@gmail.com> wrote:
>>> Sorry for off-topic, but I think it can help somebody.
>>> And I need testers ;-\
>>>
>>> I have made bug fixed, improved, multi-thread safe, spring 3.0
>>> compatible JavaScriptFactory "on steroids".
>>>
>>> * https://jira.springsource.org/browse/SPR-1933
>>> * Direct download:
>>> https://jira.springsource.org/secure/attachment/16139/org.springframework.scripting.rhino.zip
>>> * Examples: https://jira.springsource.org/browse/SPR-1933?focusedCommentId=50770&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_50770
>>>
>>>
>>> It is Rhino javascript support for Spring framework (core, not mvc).
>>> Spring supports out-of-box BeanShell, JRuby and Groovy.
>>> With JavaScriptFactory you can write your Spring beans in Javascript.
>>>
>>>
>>> Russian announce (with many examples):
>>> http://community.livejournal.com/ru_java/901310.html
>>>
>>
>

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

Posted by "Andrey P.Rybin" <ap...@gmail.com>.
Bob Schellink wrote:
does it mean you write your Click page in a dynamic language?


Yes! Exactly! But nothing special for Click ;-/

I found bug, that prevents using this feature.
https://issues.apache.org/jira/browse/CLK-622

But I did example with workaround.

Example: How to write Spring-powered Click Pages in javascript?
===============================================
(if you don't need Spring you can use javascript more "directly")

1) download JavaScriptFactory sources and build them (or just put in
your project sources)

2) make page htm template as usual (JsPage.htm in this example)

3) put in your spring.xml:
  <!-- enable script beans -->
  <bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"
/>

  <!-- id = your page name converted to bean name (1st letter in
lowercase), net.sf.apr.spring.JavaScriptFactory - my class, you can
put it in your package or  in org.springframework.scripting.rhino
package -->
  <bean id="jsPage" class="net.sf.apr.spring.JavaScriptFactory"
scope="prototype">
    <constructor-arg index="0" value="classpath:JsPage.js" /><!-- use
this script in WEB-INF/classes/JsPage.js -->
    <constructor-arg index="1"><null /></constructor-arg>
  </bean>

4) Click hack/workaround:
put empty
public class JsPage extends Page {}
in package from click.xml pages.package

5) write your javascript ;-)
Example script is attached.

I found two problems:
1) autocomplete doesn't work (IDE doesn't know this kind of DOM model ;-)
2) autobinding doesn't work - hmm... may be put it to JIRA?
Click could support not only fields, but getters [public type getField()] too.
Because Rhino can generate methods, but can't fields (it is obvious).




On Thu, Feb 4, 2010 at 18:03, Andrey P.Rybin <ap...@gmail.com> wrote:
> After some investigation - It isn't off-topic!
>
> It is cool feature.
>
> I will make example in near time:
>
> How to make Click application without javac (and .java files at all)!
>
> Rails and Grails will be dead.
>
> Dynamic Click is coming ;-)
>
>
>
> On Wed, Feb 3, 2010 at 21:37, Andrey P.Rybin <ap...@gmail.com> wrote:
>> Sorry for off-topic, but I think it can help somebody.
>> And I need testers ;-\
>>
>> I have made bug fixed, improved, multi-thread safe, spring 3.0
>> compatible JavaScriptFactory "on steroids".
>>
>> * https://jira.springsource.org/browse/SPR-1933
>> * Direct download:
>> https://jira.springsource.org/secure/attachment/16139/org.springframework.scripting.rhino.zip
>> * Examples: https://jira.springsource.org/browse/SPR-1933?focusedCommentId=50770&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_50770
>>
>>
>> It is Rhino javascript support for Spring framework (core, not mvc).
>> Spring supports out-of-box BeanShell, JRuby and Groovy.
>> With JavaScriptFactory you can write your Spring beans in Javascript.
>>
>>
>> Russian announce (with many examples):
>> http://community.livejournal.com/ru_java/901310.html
>>
>

Re: Off-topic: small announce for Spring and/or Rhino/javascript users

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

Sounds interesting, does it mean you write your Click page in a dynamic language? In ClickClick I 
have done some work on reloading pages by creating new classloaders. Thus after a recompile, the new 
page is loaded without having to restart the server. This approach doesn't yet work for stateful 
pages though.

kind regards

bob

On 5/02/2010 12:03 AM, Andrey P.Rybin wrote:
> After some investigation - It isn't off-topic!
>
> It is cool feature.
>
> I will make example in near time:
>
> How to make Click application without javac (and .java files at all)!
>
> Rails and Grails will be dead.
>
> Dynamic Click is coming ;-)
>
>
>
> On Wed, Feb 3, 2010 at 21:37, Andrey P.Rybin<ap...@gmail.com>  wrote:
>> Sorry for off-topic, but I think it can help somebody.
>> And I need testers ;-\
>>
>> I have made bug fixed, improved, multi-thread safe, spring 3.0
>> compatible JavaScriptFactory "on steroids".
>>
>> * https://jira.springsource.org/browse/SPR-1933
>> * Direct download:
>> https://jira.springsource.org/secure/attachment/16139/org.springframework.scripting.rhino.zip
>> * Examples: https://jira.springsource.org/browse/SPR-1933?focusedCommentId=50770&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_50770
>>
>>
>> It is Rhino javascript support for Spring framework (core, not mvc).
>> Spring supports out-of-box BeanShell, JRuby and Groovy.
>> With JavaScriptFactory you can write your Spring beans in Javascript.
>>
>>
>> Russian announce (with many examples):
>> http://community.livejournal.com/ru_java/901310.html
>>
>