精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-09-29
As mentioned in my last entry, WebWork now uses RIFE's continuation engine to provide a great new way to develop web applications. Now, if you choose, you can develop your applications using logical loops and control structures. This is effectively, as Bruce Tate likes to call it, a higher level way to express your program. A simple example is the following code: public class Guess extends ActionSupport { int guess; public String execute(); throws Exception { int answer = new Random();.nextInt(100); + 1; int tries = 5; while (answer != guess && tries > 0); { pause(SUCCESS);; if (guess > answer); { addFieldError("guess", "Too high!");; } else if (guess < answer); { addFieldError("guess", "Too low!");; } tries--; } if (answer == guess); { addActionMessage("You got it!");; } else { addActionMessage("You ran out of tries, the answer was " + answer);; } return SUCCESS; } public void setGuess(int guess); { this.guess = guess; } } Note how the conceptual "loop" of a number guessing game can now actually be represented as a loop in your Java code? Using RIFE's continuation engine, the class is instrumented to do some tricky stuff underneath, allowing the execution to start immediately after a pause(); call. The result is a much more logic action. 哪位了解RIFE,能否解释一下? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-09-29
cool......
有状态 v.s 无状态 |
|
返回顶楼 | |
发表时间:2005-09-29
Readonly 写道 cool......
有状态 v.s 无状态 你说的哪个变量是有状态?好在哪里 |
|
返回顶楼 | |
发表时间:2005-09-29
看不懂用法,不过知道它能达到什么目的
好奇怪的东东 |
|
返回顶楼 | |
发表时间:2005-09-29
scud 写道 看不懂用法,不过知道它能达到什么目的
好奇怪的东东 还有我看到了 WebWork + Ivy = Awesome 在 blog上有: Ivy does really make things easier doesn't it. We're using it now in Spring Web Flow, a component that can be embedded in many environments, to support automating the .jar dependency configurations for those environments. For example, we provide a "Struts" SWF configuration, a default "mvc" configuration for Spring MVC, a "JSF" configuration, etc. You simply tell Ivy the configuration you need, and all of the specific dependencies are pulled down automatically, and transitively! 这个 Ivy又是什麽概念? 虽然他可能不直接影响使用 webwork,但是我很想了解他们的作用,仅仅对性能而言么 ![]() |
|
返回顶楼 | |
发表时间:2005-09-29
ivy是做配置的,和程序没关系
在这里ivy用来管理lib及其版本 保证大家用一样的lib,并且版本一致.而且能自动下载. |
|
返回顶楼 | |
发表时间:2005-09-29
scud 写道 ivy是做配置的,和程序没关系
在这里ivy用来管理lib及其版本 保证大家用一样的lib,并且版本一致.而且能自动下载. 噢,那和 编写ww无关了。 webwork有没有像 Struts Test那样的自动化测试工具? |
|
返回顶楼 | |
发表时间:2005-09-29
webwork 的action本来就是测试友好的,自己写unit test即可.
|
|
返回顶楼 | |
发表时间:2005-09-29
pause(SUCCESS);
会显示SUCCESS页面, 当用户提交后,循环继续 |
|
返回顶楼 | |
发表时间:2005-09-30
edgeloner 写道 webwork 的action本来就是测试友好的,自己写unit test即可.
我看了使用 JUnit 测试webwork的代码: http://www.opensymphony.com/webwork/wikidocs/JUnit.html 看到用了 Mock,比较麻烦,好像只能使用 Mock对他进行测试,但是 普通的Servlet也是可以使用 Mock测试的,那麽Webwork的测试友好比普通的Servlet方便在哪里? 或者有没有更方便的方法测试他?[/url] |
|
返回顶楼 | |