You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Takashi Okamoto <to...@gloria.or.tp> on 2004/10/31 15:03:52 UTC

Scripting Support commandButton

Hi,

I made improved commandButton which support scripting support with
BSF(Apache Jakarta Bean Scription Framework). For example.

[jsp]
<%@ taglib prefix="nv" uri="http://nirvana.ultimania.org/jsf" %>
..
<nv:commandButton type="submit" action="&calc.rb" />

[Ruby Script(WEB-INF/script/calc.rb]
$bean.setResult($bean.getNumA()+$bean.getNumB())
print $bean.getResult()
"success";

calc.rb is executed when commandButton is pressed. $bean is managed
bean. Any managed beans are refered as global variables in
script. This taglib supports JavaScript and Python and any other
script language supported by BSF.

This function makes extreme easily JSF development. You don't need
recompile Java class to modify bussiness logic.

I made this commandButton for Nirvana framework (http://ultimania.org/nirvana/).
However, if you think this is good idea, I would like to contribute
my code for MyFaces.

Here is demo application included sourcecode:

http://tidus.ultimania.org/tmp/bsf-demo.war

This demo includes MyFaces and you can try it immediately:)

greetings,

Takashi Okamoto


examples webapp broken

Posted by Sylvain Vieujot <sv...@apache.org>.
It appears the examples webapp doesn't work anymore.
When I try to deploy it under tomcat 5.5, I just get blank pages :
<html><body></body></html>

I know we had this problem once already, but I don't remember very well
what it was.
I think it had to do with a JspViewHandlerImp, but I'm really not sure,
as I wasn't the one who fixed it.
Anyone has the same problem ?

The other applications where I'm using the same myfaces.jar work though.

P.S. I was about to commit some changes, so I wanted to test them when I
discovered this. However, it appears that the version prior to the
changes has the same problems.
I'm going to commit the new component anyway, as it doesn't seem to be
the culprit, and it works fine in my other applications.

Sylvain.


Re: Scripting Support commandButton

Posted by Takashi Okamoto <to...@gloria.or.tp>.
From: Manfred Geiler <ma...@apache.org>
Subject: Re: Scripting Support commandButton
Date: Tue, 02 Nov 2004 09:27:15 +0100
> My personal opinion is, that it's better to NOT mix GUI design and 
> business logic within a JSF.

Of course I thought:) Devleloper can execute another scripts from the
script is called by JSF. Nested scripts become model and the script
called by JSF become controller such as Struts Action Class.

> Unfortunately my time is very limited at the moment. Anyone willing to 
> help Takashi make a complete MyFaces component out of his
> commandButton?

Current demo is just prototype. I can refactor my taglib for
myfaces. At least changing license and package name, and adding cache
support should be done by me. If someone can commit them, I'll do it
before commit.

But I would like to ask one point. Where should I implement my
function? I have a two opinion:

(i)add bsf function into
     org.apache.myfaces.taglib.html.ext.HtmlCommandButtonTag and
     org.apache.myfaces.taglib.html.ext.HtmlCommandLinkTag.

(ii)create new component at  src/components/org/apache/myfaces/custom/bsf
    and Change tag class into:
          BSFHtmlCommandButtonTag.java
          BSFHtmlCommandLinkTag.java

(i) seems smart way. When BSF extension detect string which is
starting '&' like "&test.rb", action is recognized as script. If not,
it manners plain commandButton and commandLink. Detecting script takes
quite a few penalty and it's not influence performance. However
MyFaces HtmlCommandButtonTag break compatibility for JSF when
from-outcome value takes the string "&xxxx". x:commandButton and
x:commandLink are MyFaces specific features and I think (i) is not
become problem because developer can use plain h:commandXXXX if he keep
compatibility with JSF. (ii) doesn't break any compatibility. But two
tags will be added.


BTW, I contributed some bugs fix and Japanese localization already. If
I will become commiter with above contribute, I'm happy. I'm already
Debian Official Developer and contribute some Java projects. I'm also
developping Nirvana Framework which compile HTML into JSP 
(http://ultimania.org/nurvana/).

greetings,

Takashi Okamoto


Re: Scripting Support commandButton

Posted by Manfred Geiler <ma...@apache.org>.
Takashi,
Thanks for your offer.
My personal opinion is, that it's better to NOT mix GUI design and 
business logic within a JSF. This is one of the most important issues 
that is adressed by the MVC (model view controller) pattern. The clear 
separation between model and view is a paradigm.
On the other hand, your component is of course a convenient thing during 
development. And some people might find it useful in production too. I 
understand that the MVC principles are not a dogma for everyone  ;-)

Unfortunately my time is very limited at the moment. Anyone willing to 
help Takashi make a complete MyFaces component out of his commandButton?

Thanks,
Manfred


Takashi Okamoto wrote:
> Hi,
> 
> I made improved commandButton which support scripting support with
> BSF(Apache Jakarta Bean Scription Framework). For example.
> 
> [jsp]
> <%@ taglib prefix="nv" uri="http://nirvana.ultimania.org/jsf" %>
> ..
> <nv:commandButton type="submit" action="&calc.rb" />
> 
> [Ruby Script(WEB-INF/script/calc.rb]
> $bean.setResult($bean.getNumA()+$bean.getNumB())
> print $bean.getResult()
> "success";
> 
> calc.rb is executed when commandButton is pressed. $bean is managed
> bean. Any managed beans are refered as global variables in
> script. This taglib supports JavaScript and Python and any other
> script language supported by BSF.
> 
> This function makes extreme easily JSF development. You don't need
> recompile Java class to modify bussiness logic.
> 
> I made this commandButton for Nirvana framework (http://ultimania.org/nirvana/).
> However, if you think this is good idea, I would like to contribute
> my code for MyFaces.
> 
> Here is demo application included sourcecode:
> 
> http://tidus.ultimania.org/tmp/bsf-demo.war
> 
> This demo includes MyFaces and you can try it immediately:)
> 
> greetings,
> 
> Takashi Okamoto
> 
> 
>