You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/09/27 16:07:58 UTC

cvs commit: jakarta-commons-sandbox/jelly/xdocs jellyswing.xml faq.xml

jstrachan    2002/09/27 07:07:58

  Modified:    jelly/xdocs jellyswing.xml faq.xml
  Log:
  Updated the FAQ with a new entry from Kurt's question and added some documentation about JellySwing and JellyRunner
  
  Revision  Changes    Path
  1.2       +39 -0     jakarta-commons-sandbox/jelly/xdocs/jellyswing.xml
  
  Index: jellyswing.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/xdocs/jellyswing.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jellyswing.xml	31 Jul 2002 11:42:47 -0000	1.1
  +++ jellyswing.xml	27 Sep 2002 14:07:58 -0000	1.2
  @@ -36,6 +36,45 @@
           Then Jelly script can be used to create the view and bind in the models.
         </p>
       </section>
  +    
  +    <section name="JellyRunner"> 
  +      <p>
  +        JellyRunner is a simple example Swing user interface written with JellySwing.
  +        You can view the source to it
  +        <a href="http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/swing/run.jelly?rev=HEAD">here</a>
  +      </p>
  +      <p>
  +        If you invoke it via the following command you will get a small Swing UI that allows you to
  +        choose Jelly scripts to invoke, within the current JVM.
  +      </p>
  +      <source>
  +	maven jelly:runner
  +      </source>
  +      <p>
  +        This makes developing Jelly scripts and JellySwing scripts in particular, much more RAD-like.
  +        You can keep JellyRunner open, edit a Jelly script and just hit the 'Run' button and the
  +        script executes instantaneously, there's no waiting for a JVM to startup.
  +      </p>
  +    </section>
  +    
  +    <section name="Comparing JellySwing with Java code for Swing"> 
  +      <p>
  +        There's a simple demo written by Otto von Wachter which demonstrates how Jelly can be used
  +        for templating HTML.
  +      </p>
  +      <p>
  +        The demo was orignally written in
  +        <a href="http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/demos/HomepageBuilder.java?rev=HEAD">Java code</a>
  +         
  +        to implement a simple Swing UI
  +        As an experiment the same Swing user interface has been written 
  +       <a href="http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/demos/homepageBuilder.jelly?rev=HEAD">as a JellyScript</a>
  +        as well.
  +        While this is a fairly simple Swing UI and not a particularly great example of the power of JellySwing,
  +        it does highlight the main difference between the two appraches.
  +      </p>
  +    </section>
  +    
     </body>
   </document>
   
  
  
  
  1.4       +79 -0     jakarta-commons-sandbox/jelly/xdocs/faq.xml
  
  Index: faq.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/xdocs/faq.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- faq.xml	6 Jun 2002 14:23:51 -0000	1.3
  +++ faq.xml	27 Sep 2002 14:07:58 -0000	1.4
  @@ -37,6 +37,11 @@
             How do I add my own tag libraries to Jelly?
           </a>
         </li>
  +      <li>
  +        <a href="#tag-attributes">
  +          How do I use expressions and tag attributes?
  +        </a>
  +      </li>
       </ol>
       <p><strong>Building Jelly</strong></p>
       <ol>
  @@ -131,6 +136,80 @@
   </pre>
   </code>
   		</dd>
  +      </dl>
  +      
  +      <dl>
  +        <dt>
  +          <a name="tag-attributes">
  +            How do I use expressions and tag attributes?
  +          </a>
  +        </dt>
  +        <dd>
  +          Jelly uses introspection to set the properties on a Tag from the XML attribute
  +          values. If the attribute value in XML uses an expression, it will be evaluated
  +          and the result of the expression will be passed into your Tag's setter method.
  +          For example if you had the following Tag...
  +        </dd>
  +        <dd>                
  +<code>
  +<pre>
  +public class FooTag extends TagSupport {
  +  private String value;
  +		
  +  public void setValue(String value) {
  +    this.value = value;
  +  
  +    
  +  .
  +}</pre>
  +</code>
  +				</dd>
  +        <dd>                
  +        Then if you were to use it like this...	
  +<code>
  +<pre>
  +  &lt;my:foo value="${customer.fullName}"/&gt;
  +</pre>
  +</code>
  +        Then this would be equivalent in pseudocode to
  +<code>
  +<pre>
  +FooTag tag = FooTag();
  +...
  +tag.setValue( ((Customer) context.getVariable("customer")).getFullName() );
  +...
  +tag.doTag(output);
  +</pre>
  +</code>
  +			 </dd>
  +        <dd>
  +	        If ever you find that your Tag's bean property is not being set it could be that your Tag is
  +	        not properly following the bean introspection naming conventions. 
  +	        For example do you have a method called getValue() or isValue() with the wrong return type?
  +	        (In this discussion substitue 'value' for the name of your own property, it doesn't have to be called 'value' :).
  +	        For more details of the introspection rules, please checkout the Java Bean specification.
  +			 </dd>
  +        <dd>
  +          It could be that you want to coerce the value of an expression to some special type.
  +          For example if you want to evaluate the expression as an Iterator you can use a property
  +          on your Tag of type Expression so that in your Tag you can use the Expression.evaluateAsIterator()
  +          method. This is how the &lt;x:forEach&gt; tag currently is implemented for example.
  +<code>
  +<pre>
  +public class FooTag extends TagSupport {
  +  private Expression value;
  +		
  +  public void setValue(Expression value) {
  +    this.value = value;
  +  }
  +    
  +  public void doTag(XMLOutput output) {
  +    Iterator iter = expression.evaluateAsIterator();
  +    		...
  +  }
  +}</pre>
  +</code>
  +        </dd>
         </dl>
       </section>
       <section name="Building Jelly">
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>