[JBoss Seam] - Re: Fill selectOneMenu on page load.
by grdzeli_kaci
"petemuir" wrote : That (obviously) is a problem with your converter. Either try the entityConverter as I suggested or take a look at the Seam ui-example for how to write a suitable converter.
ok i tryed to write own converter, i got it from wiki :
1.Converter
| import java.io.Serializable;
| import java.util.List;
|
| import javax.faces.component.UIComponent;
| import javax.faces.context.FacesContext;
| import javax.faces.convert.Converter;
| import javax.faces.convert.ConverterException;
|
| public class ReferenceConverter implements Converter, Serializable{
| private static final long serialVersionUID = -6268456071880135380L;
| private static final String EMPTY = "__EMPTY__";
| private List<Object> values;
| public ReferenceConverter(List vals) {
| this.values = vals;
| }
| public String getAsString(FacesContext facesContext,
| UIComponent component,
| Object obj) {
| if (obj == null) return EMPTY;
| if ("-1".equals(obj)) return EMPTY;
|
| String val = String.valueOf( obj.hashCode() );
| return val;
| }
| public Object getAsObject(FacesContext facesContext,
| UIComponent component,
| String str)
| throws ConverterException {
| if (str == null || str.length()==0 || EMPTY.equals(str)) {
| return null;
| }
| int hash = Integer.valueOf(str).intValue();
| for (Object val : values) {
| if ( val!=null && val.hashCode()==hash ) {
| return val;
| }
| }
| return null;
| }
| }
|
2. i posted session bean above;
3 and jps :
| <h:selectOneMenu styleClass="font_style" required="true" value="" converter="#{billAdmin.converter}">
| <s:selectItems value="#{billAdmin.langItems}" var="langItems" label="#{langItems.name}" />
| </h:selectOneMenu>
|
what i did wrong ?
i could not find about converter into seam-ui examples.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018752#4018752
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4018752
19Â years, 2Â months
[Persistence, JBoss/CMP, Hibernate, Database] - Unable to load to deserialize result
by morenito9000
Hi all,
I store attachments file (like jpg, bmp, doc, pdf) inside a db table (postgresql db, column type is BYTEA).
Insert is performed via a Stateful SessionBean that uses an Entity Bean.
(at Entity Level the db column is mapped using the generic Object class).
Insert is ok.
When I try to read the attachments I use a Stateless SessioBean
that calls a DAO Class (inside DAO Class, JDBC code:
"select column from table ...." then I apply resulSet.getObject()
method).
Reading is ok.
But when I try to remove the attachment (EntityBean remove() method)
I get a strange exception.
| ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
| java.sql.SQLException: Unable to load to deserialize result: java.io.StreamCorruptedException: invalid stream header
|
I think it's something related to serialization.
Object class is not the proper class I must use to map a BYTEA DB column ?
I use JBOSS 3.2.3 and Postgesql 7.4.5.
Any help is very very appreciated.
Thank you for your help.
Ciao
Moreno
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018750#4018750
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4018750
19Â years, 2Â months
[Beginners Corner] - Unable to load to deserialize result
by morenito9000
Hi all,
I store attachments file (like jpg, bmp, doc, pdf) inside a db table (postgresql db, column type is BYTEA).
Insert is performed via a Stateful SessionBean that uses an Entity Bean.
(at Entity Level the db column is mapped using the generic Object class).
Insert is ok.
When I try to read the attachments I use a Stateless SessioBean
that calls a DAO Class (inside DAO Class, JDBC code:
"select column from table ...." then I apply resulSet.getObject()
method).
Reading is ok.
But when I try to remove the attachment (EntityBean remove() method)
I get a strange exception.
| ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
| java.sql.SQLException: Unable to load to deserialize result: java.io.StreamCorruptedException: invalid stream header
|
I think it's something related to serialization.
Object class is not the proper class I must use to map a BYTEA DB column ?
I use JBOSS 3.2.3 and Postgesql 7.4.5.
Any help is very very appreciated.
Thank you for your help.
Ciao
Moreno
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018749#4018749
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4018749
19Â years, 2Â months