You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org> on 2006/11/20 06:45:05 UTC

[jira] Resolved: (TAPESTRY-264) Consider making components and pages POJO like

     [ http://issues.apache.org/jira/browse/TAPESTRY-264?page=all ]

Jesse Kuhnert resolved TAPESTRY-264.
------------------------------------

    Fix Version/s: 5.0
       Resolution: Fixed

> Consider making components and pages POJO like
> ----------------------------------------------
>
>                 Key: TAPESTRY-264
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-264
>             Project: Tapestry
>          Issue Type: New Feature
>          Components: Framework
>            Reporter: Joni Suominen
>             Fix For: 5.0
>
>
> Please, consider making Tapestry components more POJO like. That is, the XML sepcification should be fully optional and components non-abstract. This would make Tapestry components more natural (Java like) and very easy to test. Also, it would enable better intergation with IOC containers (like Spring) since these POJOs could be managed using the chosen IOC. Below is an example taken from Howard's blog and implemented as a POJO. I added one extra feature to the example, the performed computations are tracked in a persistent property.
> Here's some suggestions:
> 1. Add Java 5 annotations to configure the properties (the XML would be supported too).
> 2. Implement page pooling in a more transparent way. Normal Java properties (firstNumber and secondNumber below) should be treated like Tapestry's non-persistent properties (their state should be resetted for each cycle).
> 3. Use defaulting for parameter configuration. By default all public JavaBean setters are optional component parameters. This default could be overwritten in XML configuration (or Java 5 annotation).
> /**
>  *  Calculator example using the hypothetical Tapestry. No xml config needed.
>  */
> public class CalculatorPage extends BasePage {
>   @PersistentProperty
>   private List computations = new ArrayList(); // same as init-value="new java.util.ArrayList()"
>   private int firstNumber;
>   private int secondNumber = 10; // same as init-value="10"
>   public void setFirstNumber(int firstNumber) {
>       this.firstNumber = firstNumber;
>   }
>   public void setSecondNumber(int secondNumber) {
>       this.secondNumber = secondNumber;
>   }
>   public int getFirstNumber() {
>       return firstNumber;
>   }
>   public int getSecondNumber() {
>       return secondNumber;
>   }
>   private Calculator _calculator = new  Calculator();
>   public void add(IRequestCycle cycle) {
>     int result = _calculator.add(firstNumber, secondNumber);
>     computations.add(new Addition(firstNumber, secondNumber);
>     showResult(result);
>   }
>   public void multiply(IRequestCycle cycle) {
>     int result = _calculator.multiply(firstNumber, secondNumber);
>     computations.add(new Multiplication(firstNumber, secondNumber);
>     showResult(result);
>   }
>   private void showResult(int result) {
>     IRequestCycle cycle = getRequestCycle();
>     ShowResult page = (ShowResult) cycle.getPage("ShowResult");
>     page.setFirstNumber(firstNumber);
>     page.setSecondNumber(secondNumber);
>     page.setResult(result);
>     cycle.activate(page);
>   }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org