Re: [Fwd: New role requested in the jsftemplating project]
Looks great!
Thanks,
Ken
Ed Chen wrote:
> Ken,
>
> I have the code diff attached. Please review!
>
> thanks,
> Ed
>
> Ken Paulsen wrote:
>
>> Hi Ed,
>>
>> Yes, I've been making those types of conversions (I wasn't sure if you
>> meant something else I didn't yet know about... b/c there's a lot I
>> don't know!). If you look in the ...layout.template package, these are
>> the new files that I'm still working on and use generics. I only
>> recently decided to take advantage of 1.5 features...
>> LayoutElementBase.java has been around for over a year w/o little or no
>> changes.
>>
>> Feel free to jump in and make the changes, I'd be happy to review the
>> changes before or after you check it in. Also, if you want to see CVS
>> notifications, you can subscribe to the cvs mail alias @
>> jsftemplating.dev.java.net. I also decided to cc the
>> dev_at_jsftemplating.dev.java.net alias b/c this might be of interest to
>> others on that alias.
>>
>> Thanks!!
>>
>> Ken
>>
>> Ed Chen wrote:
>>
>>
>>> Ken,
>>>
>>> Here's one example of what I mean:
>>>
>>> in com.sun.jsftemplating.layout.descriptors.LayoutElementBase
>>>
>>> if
>>>
>>> private List _layoutElements = new ArrayList();
>>>
>>> is declared as
>>>
>>> private List<LayoutElement> _layoutElements = new
>>> ArrayList<LayoutElement>();
>>>
>>> and we change the interface method of LayoutElement from
>>>
>>> public List getChildLayoutElements() {
>>>
>>> to
>>>
>>> public List<LayoutElement> getChildLayoutElements() {
>>>
>>> then in all usage of LayoutElement.getChildLayoutElements() as in
>>> followings:
>>>
>>> [LayoutViewHandler.java at line 163, column 35] Iterator it =
>>> elt.getChildLayoutElements().iterator();
>>> [LayoutDefinition.java at line 166, column 23] Iterator it =
>>> parent.getChildLayoutElements().iterator();
>>> [LayoutElementBase.java at line 239, column 20] Iterator it =
>>> getChildLayoutElements().iterator();
>>> [CommandActionListener.java at line 199, column 20] Iterator it =
>>> elt.getChildLayoutElements().iterator();
>>>
>>> the iterator loop can be:
>>>
>>> Iterator<LayoutElement> it = elt.getChildLayoutElements().iterator();
>>> LayoutElement childElt;
>>> UIComponent child = null;
>>> while (it.hasNext()) {
>>> childElt = it.next();
>>> .....
>>>
>>> no need to the typecast the return object of it.next() into
>>> LayoutElement. if you like, i can change the above and send you a code
>>> diff for your review.
>>>
>>> thanks,
>>> Ed
>>>
>>> Ken Paulsen wrote:
>>>
>>>
>>>> Yep, that's the expected output... complete w/ some debug statements
>>>> that I was printing out.
>>>>
>>>> Can you explain more about the generic iterator? ...I'm still
>>>> learning
>>>> the new features of Java 5 and probably just didn't know how to do
>>>> it. I have been switching over some of the iteration stuff using "for
>>>> (variable : list) {}" type of syntax. I've also started to use
>>>> generics
>>>> variable definitions: "<type>"... but I haven't converted all the code
>>>> to do this yet.
>>>>
>>>> As I mentioned before, if you see something that you'd like to
>>>> change...
>>>> feel free. ;)
>>>>
>>>> Ken
>>>>
>>>>
>>>>
>>>>
>
> ------------------------------------------------------------------------
>
> Index: LayoutViewHandler.java
> ===================================================================
> RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/LayoutViewHandler.java,v
> retrieving revision 1.3
> diff -r1.3 LayoutViewHandler.java
> 168c168
> < Iterator it = elt.getChildLayoutElements().iterator();
> ---
>
>> Iterator<LayoutElement> it = elt.getChildLayoutElements().iterator();
>>
> 172c172
> < childElt = (LayoutElement) it.next();
> ---
>
>> childElt = it.next();
>>
> Index: descriptors/LayoutDefinition.java
> ===================================================================
> RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/descriptors/LayoutDefinition.java,v
> retrieving revision 1.1
> diff -r1.1 LayoutDefinition.java
> 166c166
> < Iterator it = parent.getChildLayoutElements().iterator();
> ---
>
>> Iterator<LayoutElement> it = parent.getChildLayoutElements().iterator();
>>
> 170c170
> < context, id, (LayoutElement) it.next(), parentComponent);
> ---
>
>> context, id, it.next(), parentComponent);
>>
> Index: descriptors/LayoutElement.java
> ===================================================================
> RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/descriptors/LayoutElement.java,v
> retrieving revision 1.1
> diff -r1.1 LayoutElement.java
> 65c65
> < * This method returns the child LayoutElements as a List.
> ---
>
>> * This method returns the child LayoutElements as a List of LayoutElement.
>>
> 69c69
> < public List getChildLayoutElements();
> ---
>
>> public List<LayoutElement> getChildLayoutElements();
>>
> Index: descriptors/LayoutElementBase.java
> ===================================================================
> RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/descriptors/LayoutElementBase.java,v
> retrieving revision 1.1
> diff -r1.1 LayoutElementBase.java
> 79c79
> < * <p> This method returns the {_at_link LayoutElement}s as a List.</p>
> ---
>
>> * <p> This method returns the {_at_link LayoutElement}s as a List of LayoutElement.</p>
>>
> 83c83
> < public List getChildLayoutElements() {
> ---
>
>> public List<LayoutElement> getChildLayoutElements() {
>>
> 239c239
> < Iterator it = getChildLayoutElements().iterator();
> ---
>
>> Iterator<LayoutElement> it = getChildLayoutElements().iterator();
>>
> 241c241
> < childElt = (LayoutElement) it.next();
> ---
>
>> childElt = it.next();
>>
> 449c449
> < private List _layoutElements = new ArrayList();
> ---
>
>> private List<LayoutElement> _layoutElements = new ArrayList<LayoutElement>();
>>
> Index: event/CommandActionListener.java
> ===================================================================
> RCS file: /cvs/jsftemplating/src/java/com/sun/jsftemplating/layout/event/CommandActionListener.java,v
> retrieving revision 1.1
> diff -r1.1 CommandActionListener.java
> 199c199
> < Iterator it = elt.getChildLayoutElements().iterator();
> ---
>
>> Iterator<LayoutElement> it = elt.getChildLayoutElements().iterator();
>>
> 201c201
> < child = (LayoutElement) it.next();
> ---
>
>> child = it.next();
>>