[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-04 Thread CptnKirk
Do you really need a lot of converters?  The @SelectItems binder does the 
conversion from whatever to SelectItem for you.  I see you're using the Object 
strategy.  The strategy works fine if you already have a lot of converters, but 
it wasn't my intention that you create additional converters to use 
@SelectItems.

Another way that would avoid the extra converter classes would be to write 
another binder that takes the selected value from the UISelect{One, Many} 
component and did the appropriate lookup from the original @SelectItems 
collection.

This has been on my TODO list for a while.  Between holidays, weddings, and 
work my time just seems to evaporate.  I will of course add this to my existing 
contribution once finished.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955334#3955334

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955334

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-04 Thread supernovasoftware.com
This is what I am using now.  Every Entity in my project has an id named id 
that is a Long.  So all I have to do is add the interface Idable to the entity. 
 There is no doubt a better way.  With discussions like this we can find an 
optimal technique that everyone can easily use with minimal setup.

Looking it up from the original list seems like a good idea.

Comments and or criticism are welcome.


  | public interface Idable {
  | public Long getId();
  | }
  | 

I modifed some code from other posts and came up with the following.  Generic 
converter.


  | public abstract class LookupConverterT extends Idable implements Converter
  | {
  |   private ClassT entityClass;
  |   private EntityManager em;
  | 
  |   public LookupConverter(ClassT entityClass, EntityManager em) {
  | this.entityClass = entityClass;
  | this.em = em;
  |   }
  | 
  |   @SuppressWarnings(unchecked)
  |   public String getAsString(FacesContext facesContext, UIComponent 
component, Object obj)
  |   {
  | T t =(T) obj;
  | if(t == null || t.getId()==null)
  | {
  |   return ;
  | }
  | else
  | {
  |   return t.getId().toString();
  | }
  |   }
  | 
  |   public Object getAsObject(FacesContext facesContext, UIComponent 
component, String str)
  |  throws ConverterException
  |   {
  | return getObject(str);
  |   }
  | 
  |   private Object getObject(String str)
  |   {
  | try
  | { 
  |   return em.find(entityClass, Long.valueOf(str));
  | }
  | catch (NumberFormatException e)
  | {
  |   throw new ConverterException(new FacesMessage(You must select 
something.));
  | }
  |   }
  | }
  | 

I am using inner classes to deliver my converters form a SLSB.  I am passing 
the EntityManager to the constructor.


  | @Stateless
  | @Name(converterFactory)
  | public class ConverterFactoryBean implements ConverterSizeFactory
  | {
  |   @Logger private Log log;
  |   @PersistenceContext EntityManager em;
  | 
  |   public Converter getSizeConverter()
  |   {
  | return new SizeConverter(em);
  |   }
  | 
  |   public static class SizeConverter extends LookupConverterSize
  |   {
  | public SizeConverter(EntityManager em)
  | {
  |   super(Size.class, em);
  | }
  |   }
  | }
  | 

I have a facelets taglib that creates the select field and renders the message 
in a mouseover icon with another custom facelets tag.

  | ui:composition xmlns:ui=http://java.sun.com/jsf/facelets; 
xmlns=http://www.w3.org/1999/xhtml; xmlns:h=http://java.sun.com/jsf/html; 
xmlns:f=http://java.sun.com/jsf/core;
  |   tr class=tr0
  | td#{selectFieldLabel}/td
  | td
  |   h:selectOneMenu id=#{selectFieldId} 
  |value=#{selectFieldValue}
  |class=select_std w200 
  |converter=#{selectFieldConverter}
  | f:selectItems value=#{selectFieldItems} /
  |   /h:selectOneMenu
  | /td
  | tdpt:errorsField fieldId=#{selectFieldId} //td
  |   /tr
  | /ui:composition
  | 

In the page I set it up as follows:

  |   pt:selectField2 selectFieldId=size
  |   selectFieldLabel=Size
  |   selectFieldValue=#{poCoupling.size}
  |   selectFieldItems=#{sizeSelectItems}
  |   
selectFieldConverter=#{converterFactory.sizeConverter}/
  | 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955338#3955338

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955338

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-03 Thread supernovasoftware.com
I teaked it a bit to make it a SFSB and pull a list of objects.  For anyone 
else that tries this do not put valueMethod=??? if you change the value 
stragety to valueStrategy = SelectItems.Strategy.OBJECT.

I thought for sure I needed this, but errors occur after you add the converter. 
 It kept returning the label value to the converter and chocking in my public 
String getAsString(FacesContext ctx, UIComponent component, Object value) 
method since I am looking it up by the id in the converter.

I haven't fully tested this out, but so far it really rocks.  More people 
should post their stuff to the wiki like Jim did.

All I need now is a way to have my entites convert themselves so I do not have 
to go to the trouble of making one for every type.

Is anyone close to or have a solution for this?


  | @Name(selector)
  | @Stateful
  | @Scope(ScopeType.EVENT)
  | @Interceptors(SeamInterceptor.class)
  | public class SelectorAction implements Selector, Serializable
  | {
  |   private static final long serialVersionUID = 1691282596699470676L;
  |   
  |   @Logger Log log;
  |   @PersistenceContext EntityManager em;
  | 
  |   private Grade selected;
  |   public Grade getSelected() { return selected; }
  |   public void setSelected(Grade selected) { this.selected = selected; }
  | 
  |   @SelectItems(valueStrategy = SelectItems.Strategy.OBJECT, labelMethod = 
getGrade)
  |   public List items;
  | 
  |   @Factory(items)
  |   public List getItems()
  |   {
  | items = em.createQuery(from Grade).getResultList();
  | return items;
  |   }
  | 
  |   public void select()
  |   {
  | log.info(You selected:  + selected.getGrade());
  |   }
  | 
  |   @Remove @Destroy
  |   public void destroy() { }
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954949#3954949

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954949

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-03 Thread supernovasoftware.com
One more time.  Than you Jim.  I cleaned it up even more.  I cannot believe how 
easy it is to use SelectItems now.  Your code is really clear and easy to 
follow.  I did have it working, but now it is cake. 

:-)   :+) :~)


  | @Name(selector)
  | @Stateless
  | @Interceptors(SeamInterceptor.class)
  | public class SelectorAction implements Selector
  | {
  |   @EJB GradeDAO gradeDAO;
  |   
  |   @SelectItems(valueStrategy = SelectItems.Strategy.OBJECT, labelMethod = 
getGrade)
  |   private List gradeSelectItems;
  | 
  |   @Factory(gradeSelectItems)
  |   public List getGradeSelectItems()
  |   {
  | return gradeSelectItems = gradeDAO.getAllGrades();
  |   }
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954977#3954977

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954977

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-03 Thread CptnKirk
I'm glad it's useful.  If you put the following in your ejb-jar.xml you'll be 
able to remove the @Interceptors annotation from all of your components.  That 
should clean up the code even more.


  | ejb-jar
  |assembly-descriptor
  |   interceptor-binding
  |  ejb-name*/ejb-name
  |  
interceptor-classorg.jboss.seam.ejb.SeamInterceptor/interceptor-class
  |   /interceptor-binding
  |/assembly-descriptor
  | /ejb-jar
  | 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955143#3955143

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955143

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-03 Thread supernovasoftware.com
I was aware there was a way to remove that, but never looked into it.

I was able to clean up over 75 SLSB an SFSB.  Thx for the tip.

What are your thoughts on a slick converter.  I am using one that forces me to 
make my entites implement an interface.

Not a big problem, but I am looking for a slick way to avoid that.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3955154#3955154

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3955154

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-02 Thread CptnKirk
Yes.  Let me head on over to the wiki and find a place to post it.

-Jim

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954928#3954928

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954928

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-02 Thread supernovasoftware.com
Thanks Captain.  I will be looking for it.

You really seem to know your shiz.

Do you have any suggestion for a solution to the following unrelated problem?

http://www.jboss.com/index.html?module=bbop=viewtopict=85986

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954930#3954930

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954930

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-02 Thread CptnKirk
The @SelectItems example can be found on the Wiki here.

http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossSeam

It doesn't currently support selection, you'll need to use JSF EL to bind 
selected values to your controller.  This should help you get your drop down 
started though.

-Jim

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954933#3954933

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954933

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [JBoss Seam] - Re: @DataBinder and SelectItems Example

2006-07-02 Thread supernovasoftware.com
Thanks again Jim.  I will look into it.  Hopefully this type of functionality 
will be added to Seam sometime soon.

Everyone needs dropdowns. :-}  And using them should be a trivial matter.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3954937#3954937

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3954937

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user