Re: [T5] SelectObject component added to the Wiki

2007-09-05 Thread Marcelo lotif
ok! thanks! works fine, i will update the wiki

2007/8/31, Davor Hrg [EMAIL PROTECTED]:

 If you like digging into tapestry I suggest you start
 by removing beanutils dependancy and adding:
 @Inject
 private PropertyAccess propertyAccess;

 into SelectObject.java
 after that use propertyAccess instead of beanutils...
 

 I'm currently building a version that doesn't need
 SelectObject component, but uses normal select component.
 The code is more complicated than it should be, so I suppose
 I might post an enhancement ticket for the Select component.


for sure, this solution is way more complicated than it should be, but
tapestry limit us too much in this point(as it does in the DatePicker
too)... i hope there will be some better solution on the next release.

...
 if you like to start with working code ...
 here's the changed version that works for me ...




 ---
 package test.tapestry;


 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;

 import org.apache.tapestry.OptionGroupModel;
 import org.apache.tapestry.OptionModel;
 import org.apache.tapestry.internal.OptionModelImpl;
 import org.apache.tapestry.ioc.services.PropertyAccess;
 import org.apache.tapestry.ioc.services.PropertyAdapter;
 import org.apache.tapestry.util.AbstractSelectModel;

 /**
 * @author jued
 *
 * @param T
 */
 public class GenericSelectionModelT extends AbstractSelectModel {

 private String labelField;

 private ListT list;

 private final PropertyAccess adapter;

 public GenericSelectionModel(ListT list, String labelField,
 PropertyAccess adapter) {
 this.labelField = labelField;
 this.list = list;
 this.adapter = adapter;
 }

 public ListOptionGroupModel getOptionGroups() {
 return null;
 }

 public ListOptionModel getOptions() {
 ListOptionModel optionModelList = new
 ArrayListOptionModel();
 for (T obj : list) {
 if (labelField == null) {
 optionModelList.add(new
 OptionModelImpl(obj
 + , false, obj, new String[0]));
 } else {
 optionModelList.add(new OptionModelImpl(
 adapter.get(obj,
 labelField)+, false, obj, new String[0]));
 }
 }
 return optionModelList;
 }
 }

 ---



 ---
 package test.tapestry;

 import java.lang.reflect.InvocationTargetException;
 import java.util.List;

 import org.apache.tapestry.ValueEncoder;
 import org.apache.tapestry.ioc.services.PropertyAccess;
 import org.apache.tapestry.ioc.services.PropertyAdapter;

 public class GenericValueEncoderT implements ValueEncoderT {

 private ListT list;
 private final PropertyAccess access;
 private final String fieldName;

 public GenericValueEncoder(ListT list, String fieldName,
 PropertyAccess propertyAccess) {
 this.list = list;
 this.fieldName = fieldName;
 this.access = propertyAccess;
 }

 public String toClient(T obj) {
 if (fieldName == null) {
 return obj + ;
 } else {
 return access.get(obj,fieldName)+;
 }
 }

 public T toValue(String string) {
 for (T obj : list) {
 if (fieldName == null) {
 if ((obj + ).equals(string)) {
 return obj;
 }
 } else {
 if (access.get(obj,
 fieldName).equals(string)) {
 return obj;
 }
 }
 }
 return null;
 }
 }

 ---




 ---
 package test.tapestry.components;

 import java.util.List;
 import java.util.Locale;

 import org.apache.tapestry.Binding;
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.FieldValidator;
 import 

Re: [T5] SelectObject component added to the Wiki

2007-09-05 Thread Davor Hrg
I've created a simpler version, this is as simple as I could make it
without requiring changes to select component.

http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects

I belive that having objects in the list is a common case enough
so simplifying a task like this should be a goal later on in development


Davor Hrg


On 9/5/07, Marcelo lotif [EMAIL PROTECTED] wrote:

 ok! thanks! works fine, i will update the wiki

 2007/8/31, Davor Hrg [EMAIL PROTECTED]:
 
  If you like digging into tapestry I suggest you start
  by removing beanutils dependancy and adding:
  @Inject
  private PropertyAccess propertyAccess;
 
  into SelectObject.java
  after that use propertyAccess instead of beanutils...
  
 
  I'm currently building a version that doesn't need
  SelectObject component, but uses normal select component.
  The code is more complicated than it should be, so I suppose
  I might post an enhancement ticket for the Select component.


 for sure, this solution is way more complicated than it should be, but
 tapestry limit us too much in this point(as it does in the DatePicker
 too)... i hope there will be some better solution on the next release.

 ...
  if you like to start with working code ...
  here's the changed version that works for me ...
 
 
 
 
 
 ---
  package test.tapestry;
 
 
  import java.lang.reflect.InvocationTargetException;
  import java.util.ArrayList;
  import java.util.List;
 
  import org.apache.tapestry.OptionGroupModel;
  import org.apache.tapestry.OptionModel;
  import org.apache.tapestry.internal.OptionModelImpl;
  import org.apache.tapestry.ioc.services.PropertyAccess;
  import org.apache.tapestry.ioc.services.PropertyAdapter;
  import org.apache.tapestry.util.AbstractSelectModel;
 
  /**
  * @author jued
  *
  * @param T
  */
  public class GenericSelectionModelT extends AbstractSelectModel {
 
  private String labelField;
 
  private ListT list;
 
  private final PropertyAccess adapter;
 
  public GenericSelectionModel(ListT list, String labelField,
  PropertyAccess adapter) {
  this.labelField = labelField;
  this.list = list;
  this.adapter = adapter;
  }
 
  public ListOptionGroupModel getOptionGroups() {
  return null;
  }
 
  public ListOptionModel getOptions() {
  ListOptionModel optionModelList = new
  ArrayListOptionModel();
  for (T obj : list) {
  if (labelField == null) {
  optionModelList.add(new
  OptionModelImpl(obj
  + , false, obj, new String[0]));
  } else {
  optionModelList.add(new OptionModelImpl(
  adapter.get(obj,
  labelField)+, false, obj, new String[0]));
  }
  }
  return optionModelList;
  }
  }
 
 
 ---
 
 
 
 
 ---
  package test.tapestry;
 
  import java.lang.reflect.InvocationTargetException;
  import java.util.List;
 
  import org.apache.tapestry.ValueEncoder;
  import org.apache.tapestry.ioc.services.PropertyAccess;
  import org.apache.tapestry.ioc.services.PropertyAdapter;
 
  public class GenericValueEncoderT implements ValueEncoderT {
 
  private ListT list;
  private final PropertyAccess access;
  private final String fieldName;
 
  public GenericValueEncoder(ListT list, String fieldName,
  PropertyAccess propertyAccess) {
  this.list = list;
  this.fieldName = fieldName;
  this.access = propertyAccess;
  }
 
  public String toClient(T obj) {
  if (fieldName == null) {
  return obj + ;
  } else {
  return access.get(obj,fieldName)+;
  }
  }
 
  public T toValue(String string) {
  for (T obj : list) {
  if (fieldName == null) {
  if ((obj + ).equals(string)) {
  return obj;
  }
  } else {
  if (access.get(obj,
  fieldName).equals(string)) {
  return obj;
  }
  }
  }
  return null;
  }
  }
 
 
 

Re: [T5] SelectObject component added to the Wiki

2007-09-05 Thread Davor Hrg
oh,
I see you've already changed wiki and linked the pages,

we could discuss this issue further... and write up an enhancement request
ticket.

Davor Hrg

On 9/5/07, Davor Hrg [EMAIL PROTECTED] wrote:

 I've created a simpler version, this is as simple as I could make it
 without requiring changes to select component.

 http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects

 I belive that having objects in the list is a common case enough
 so simplifying a task like this should be a goal later on in
 development


 Davor Hrg


 On 9/5/07, Marcelo lotif [EMAIL PROTECTED] wrote:
 
  ok! thanks! works fine, i will update the wiki
 
  2007/8/31, Davor Hrg [EMAIL PROTECTED]:
  
   If you like digging into tapestry I suggest you start
   by removing beanutils dependancy and adding:
   @Inject
   private PropertyAccess propertyAccess;
  
   into SelectObject.java
   after that use propertyAccess instead of beanutils...
   
  
   I'm currently building a version that doesn't need
   SelectObject component, but uses normal select component.
   The code is more complicated than it should be, so I suppose
   I might post an enhancement ticket for the Select component.
 
 
  for sure, this solution is way more complicated than it should be, but
  tapestry limit us too much in this point(as it does in the DatePicker
  too)... i hope there will be some better solution on the next release.
 
  ...
   if you like to start with working code ...
   here's the changed version that works for me ...
  
  
  
  
  
  ---
   package test.tapestry;
  
  
   import java.lang.reflect.InvocationTargetException;
   import java.util.ArrayList;
   import java.util.List;
  
   import org.apache.tapestry.OptionGroupModel;
   import org.apache.tapestry.OptionModel ;
   import org.apache.tapestry.internal.OptionModelImpl;
   import org.apache.tapestry.ioc.services.PropertyAccess;
   import org.apache.tapestry.ioc.services.PropertyAdapter;
   import org.apache.tapestry.util.AbstractSelectModel ;
  
   /**
   * @author jued
   *
   * @param T
   */
   public class GenericSelectionModelT extends AbstractSelectModel {
  
   private String labelField;
  
   private ListT list;
  
   private final PropertyAccess adapter;
  
   public GenericSelectionModel(ListT list, String labelField,
   PropertyAccess adapter) {
   this.labelField = labelField;
   this.list = list;
   this.adapter = adapter;
   }
  
   public ListOptionGroupModel getOptionGroups() {
   return null;
   }
  
   public ListOptionModel getOptions() {
   ListOptionModel optionModelList = new
   ArrayListOptionModel();
   for (T obj : list) {
   if (labelField == null) {
   optionModelList.add(new
   OptionModelImpl(obj
   + , false, obj, new String[0]));
   } else {
   optionModelList.add(new
  OptionModelImpl(
   adapter.get(obj,
   labelField)+, false, obj, new String[0]));
   }
   }
   return optionModelList;
   }
   }
  
  
  ---
 
  
  
  
  
  ---
   package test.tapestry;
  
   import java.lang.reflect.InvocationTargetException;
   import java.util.List;
  
   import org.apache.tapestry.ValueEncoder;
   import org.apache.tapestry.ioc.services.PropertyAccess;
   import org.apache.tapestry.ioc.services.PropertyAdapter ;
  
   public class GenericValueEncoderT implements ValueEncoderT {
  
   private ListT list;
   private final PropertyAccess access;
   private final String fieldName;
  
   public GenericValueEncoder(ListT list, String fieldName,
   PropertyAccess propertyAccess) {
   this.list = list;
   this.fieldName = fieldName;
   this.access = propertyAccess;
   }
  
   public String toClient(T obj) {
   if (fieldName == null) {
   return obj + ;
   } else {
   return access.get(obj,fieldName)+;
   }
   }
  
   public T toValue(String string) {
   for (T obj : list) {
   if (fieldName == null) {
   if ((obj + ).equals(string)) {
   return obj;
  

Re: [T5] SelectObject component added to the Wiki

2007-09-05 Thread Marcelo lotif
2007/9/5, Davor Hrg [EMAIL PROTECTED]:

 I've created a simpler version, this is as simple as I could make it
 without requiring changes to select component.


http://wiki.apache.org/tapestry/Tapestry5HowtoSelectWithObjects


a saw and found it interesting, good solution

I belive that having objects in the list is a common case enough
 so simplifying a task like this should be a goal later on in
 development


i hope so :)

Davor Hrg


 On 9/5/07, Marcelo lotif [EMAIL PROTECTED] wrote:
 
  ok! thanks! works fine, i will update the wiki
 
  2007/8/31, Davor Hrg [EMAIL PROTECTED]:
  
   If you like digging into tapestry I suggest you start
   by removing beanutils dependancy and adding:
   @Inject
   private PropertyAccess propertyAccess;
  
   into SelectObject.java
   after that use propertyAccess instead of beanutils...
   
  
   I'm currently building a version that doesn't need
   SelectObject component, but uses normal select component.
   The code is more complicated than it should be, so I suppose
   I might post an enhancement ticket for the Select component.
 
 
  for sure, this solution is way more complicated than it should be, but
  tapestry limit us too much in this point(as it does in the DatePicker
  too)... i hope there will be some better solution on the next release.
 
  ...
   if you like to start with working code ...
   here's the changed version that works for me ...
  
  
  
  
  
  
 
 ---
   package test.tapestry;
  
  
   import java.lang.reflect.InvocationTargetException;
   import java.util.ArrayList;
   import java.util.List;
  
   import org.apache.tapestry.OptionGroupModel;
   import org.apache.tapestry.OptionModel;
   import org.apache.tapestry.internal.OptionModelImpl;
   import org.apache.tapestry.ioc.services.PropertyAccess;
   import org.apache.tapestry.ioc.services.PropertyAdapter;
   import org.apache.tapestry.util.AbstractSelectModel;
  
   /**
   * @author jued
   *
   * @param T
   */
   public class GenericSelectionModelT extends AbstractSelectModel {
  
   private String labelField;
  
   private ListT list;
  
   private final PropertyAccess adapter;
  
   public GenericSelectionModel(ListT list, String labelField,
   PropertyAccess adapter) {
   this.labelField = labelField;
   this.list = list;
   this.adapter = adapter;
   }
  
   public ListOptionGroupModel getOptionGroups() {
   return null;
   }
  
   public ListOptionModel getOptions() {
   ListOptionModel optionModelList = new
   ArrayListOptionModel();
   for (T obj : list) {
   if (labelField == null) {
   optionModelList.add(new
   OptionModelImpl(obj
   + , false, obj, new String[0]));
   } else {
   optionModelList.add(new
 OptionModelImpl(
   adapter.get(obj,
   labelField)+, false, obj, new String[0]));
   }
   }
   return optionModelList;
   }
   }
  
  
  
 
 ---
  
  
  
  
  
 
 ---
   package test.tapestry;
  
   import java.lang.reflect.InvocationTargetException;
   import java.util.List;
  
   import org.apache.tapestry.ValueEncoder;
   import org.apache.tapestry.ioc.services.PropertyAccess;
   import org.apache.tapestry.ioc.services.PropertyAdapter;
  
   public class GenericValueEncoderT implements ValueEncoderT {
  
   private ListT list;
   private final PropertyAccess access;
   private final String fieldName;
  
   public GenericValueEncoder(ListT list, String fieldName,
   PropertyAccess propertyAccess) {
   this.list = list;
   this.fieldName = fieldName;
   this.access = propertyAccess;
   }
  
   public String toClient(T obj) {
   if (fieldName == null) {
   return obj + ;
   } else {
   return access.get(obj,fieldName)+;
   }
   }
  
   public T toValue(String string) {
   for (T obj : list) {
   if (fieldName == null) {
   if ((obj + ).equals(string)) {
   return obj;
   }
   } else {
  

Re: [T5] SelectObject component added to the Wiki

2007-08-31 Thread Davor Hrg
If you like digging into tapestry I suggest you start
by removing beanutils dependancy and adding:
@Inject
private PropertyAccess propertyAccess;

into SelectObject.java
after that use propertyAccess instead of beanutils...


I'm currently building a version that doesn't need
SelectObject component, but uses normal select component.
The code is more complicated than it should be, so I suppose
I might post an enhancement ticket for the Select component.



...
if you like to start with working code ...
here's the changed version that works for me ...



---
package test.tapestry;


import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry.OptionGroupModel;
import org.apache.tapestry.OptionModel;
import org.apache.tapestry.internal.OptionModelImpl;
import org.apache.tapestry.ioc.services.PropertyAccess;
import org.apache.tapestry.ioc.services.PropertyAdapter;
import org.apache.tapestry.util.AbstractSelectModel;

/**
 * @author jued
 *
 * @param T
 */
public class GenericSelectionModelT extends AbstractSelectModel {

private String labelField;

private ListT list;

private final PropertyAccess adapter;

public GenericSelectionModel(ListT list, String labelField,
PropertyAccess adapter) {
this.labelField = labelField;
this.list = list;
this.adapter = adapter;
}

public ListOptionGroupModel getOptionGroups() {
return null;
}

public ListOptionModel getOptions() {
ListOptionModel optionModelList = new
ArrayListOptionModel();
for (T obj : list) {
if (labelField == null) {
optionModelList.add(new OptionModelImpl(obj
+ , false, obj, new String[0]));
} else {
optionModelList.add(new OptionModelImpl(
adapter.get(obj,
labelField)+, false, obj, new String[0]));
}
}
return optionModelList;
}
}
---


---
package test.tapestry;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.tapestry.ValueEncoder;
import org.apache.tapestry.ioc.services.PropertyAccess;
import org.apache.tapestry.ioc.services.PropertyAdapter;

public class GenericValueEncoderT implements ValueEncoderT {

private ListT list;
private final PropertyAccess access;
private final String fieldName;

public GenericValueEncoder(ListT list, String fieldName,
PropertyAccess propertyAccess) {
this.list = list;
this.fieldName = fieldName;
this.access = propertyAccess;
}

public String toClient(T obj) {
if (fieldName == null) {
return obj + ;
} else {
return access.get(obj,fieldName)+;
}
}

public T toValue(String string) {
for (T obj : list) {
if (fieldName == null) {
if ((obj + ).equals(string)) {
return obj;
}
} else {
if (access.get(obj,
fieldName).equals(string)) {
return obj;
}
}
}
return null;
}
}
---



---
package test.tapestry.components;

import java.util.List;
import java.util.Locale;

import org.apache.tapestry.Binding;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.FieldValidator;
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.OptionModel;
import org.apache.tapestry.SelectModel;
import org.apache.tapestry.SelectModelVisitor;
import org.apache.tapestry.ValidationException;
import org.apache.tapestry.ValidationTracker;
import org.apache.tapestry.ValueEncoder;
import org.apache.tapestry.annotations.BeforeRenderTemplate;
import org.apache.tapestry.annotations.Environmental;
import 

Re: [T5] SelectObject component added to the Wiki

2007-08-30 Thread Robin Helgelin
On 8/30/07, 小司 [EMAIL PROTECTED] wrote:
 I user it it works well


 select component's html source is
 option value=IndexIndex

 no /option

 how to rectify it??

 if i want to get this style ,how to modify the source
 select size=1
opiton value=1 IT department/option
 /select
  the value and display value is defferent.


Search the archives, this is due to tapestry rendering as html (note,
not xhtml), which is sgml based and doesn't require an ending tag.

-- 
regards,
Robin


Re: [T5] SelectObject component added to the Wiki

2007-08-29 Thread Davor Hrg
thnx,
very nice example,

I've liked it and modified it to use Tapestry builtin service:
PropertyAccess
instead of beanutils. If you like I can update the wiki..

Davor Hrg

On 8/28/07, Marcelo lotif [EMAIL PROTECTED] wrote:

 http://wiki.apache.org/tapestry/Tapestry5SelectObject

 --
 Atenciosamente,
 Marcelo Lotif



Re: [T5] SelectObject component added to the Wiki

2007-08-29 Thread Marcelo lotif
Hi Davor,
Can you send it to me?

2007/8/29, Davor Hrg [EMAIL PROTECTED]:

 thnx,
 very nice example,

 I've liked it and modified it to use Tapestry builtin service:
 PropertyAccess
 instead of beanutils. If you like I can update the wiki..

 Davor Hrg

 On 8/28/07, Marcelo lotif [EMAIL PROTECTED] wrote:
 
  http://wiki.apache.org/tapestry/Tapestry5SelectObject
 
  --
  Atenciosamente,
  Marcelo Lotif
 




-- 
Atenciosamente,
Marcelo Lotif


Re: [T5] SelectObject component added to the Wiki

2007-08-29 Thread Marcelo lotif
or update the wiki, whatever... use a built in service looks more
appropriate
:]

2007/8/29, Marcelo lotif [EMAIL PROTECTED]:

 Hi Davor,
 Can you send it to me?

 2007/8/29, Davor Hrg [EMAIL PROTECTED]:
 
  thnx,
  very nice example,
 
  I've liked it and modified it to use Tapestry builtin service:
  PropertyAccess
  instead of beanutils. If you like I can update the wiki..
 
  Davor Hrg
 
  On 8/28/07, Marcelo lotif  [EMAIL PROTECTED] wrote:
  
   http://wiki.apache.org/tapestry/Tapestry5SelectObject
  
   --
   Atenciosamente,
   Marcelo Lotif
  
 



 --
 Atenciosamente,
 Marcelo Lotif




-- 
Atenciosamente,
Marcelo Lotif


Re: [T5] SelectObject component added to the Wiki

2007-08-29 Thread 小司
I user it it works well


select component's html source is
option value=IndexIndex

no /option

how to rectify it??

if i want to get this style ,how to modify the source
select size=1
   opiton value=1 IT department/option
/select
 the value and display value is defferent.

2007/8/29, Marcelo lotif [EMAIL PROTECTED]:
 or update the wiki, whatever... use a built in service looks more
 appropriate
 :]

 2007/8/29, Marcelo lotif [EMAIL PROTECTED]:
 
  Hi Davor,
  Can you send it to me?
 
  2007/8/29, Davor Hrg [EMAIL PROTECTED]:
  
   thnx,
   very nice example,
  
   I've liked it and modified it to use Tapestry builtin service:
   PropertyAccess
   instead of beanutils. If you like I can update the wiki..
  
   Davor Hrg
  
   On 8/28/07, Marcelo lotif  [EMAIL PROTECTED] wrote:
   
http://wiki.apache.org/tapestry/Tapestry5SelectObject
   
--
Atenciosamente,
Marcelo Lotif
   
  
 
 
 
  --
  Atenciosamente,
  Marcelo Lotif




 --
 Atenciosamente,
 Marcelo Lotif



-- 
得与失都是生活