]
Brian Leathem commented on SEAMFACES-82:
----------------------------------------
@Priya: This is a WELD issue, and has been fixed in Weld. It's a matter of waiting
until the patched Weld (will be Weld 1.2 I believe) makes it into your preferred
application server.
In the mean time, you can find out how to replace the Weld implementation in your
container with a Weld SNAPSHOT you can build yourself. I can tell you how to do this for
Glassfish, but I do not know how for JBoss AS.
Injection in faces Converters broken
------------------------------------
Key: SEAMFACES-82
URL:
https://issues.jboss.org/browse/SEAMFACES-82
Project: Seam Faces
Issue Type: Bug
Components: CDI Integration
Affects Versions: 3.0.0.Beta2
Environment: jboss AS 6 final, windows, war deployment
Reporter: yangju
Assignee: Brian Leathem
Priority: Critical
I have a big war with seam 3 faces, persistence, internationalization, xml config, solder
modules in the web-inf/lib.
I have tried to inject managed beans into the jsf converter, but it does not matter it is
my own bean or seam's bean or weld's bean, the bean is always null. It seems that
the injection fails silently. The converter code is as follows:
package com.pearson.epen.managedBean.converter;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import org.slf4j.Logger;
import com.pearson.epen.account.model.api.TestAdmin;
import com.pearson.epen.cdi.qualifier.CentralRepo;
import com.pearson.epen.cdi.qualifier.StaticData;
@SessionScoped
@FacesConverter("convert.TestAdmin")
public class TestAdminConverter implements Converter, Serializable {
private static final long serialVersionUID = 1L;
@Inject
@StaticData
private List<TestAdmin> admins;
@Inject
private FacesContext context;
@Inject
@CentralRepo
private EntityManager em;
@Inject
private Logger log;
@PostConstruct
public void init() {
log.info("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%init");
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
try {
Long id = Long.valueOf(value);
for (TestAdmin admin : admins) {
if (admin.getId().longValue() == id.longValue()) {
return admin;
}
}
} catch (Throwable t) {
log.error("got exception", t);
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value)
{
TestAdmin testAdmin = (TestAdmin) value;
return Long.toString(testAdmin.getId());
}
}
In above code, all injections are null and the @PostConstruct method is never called.
However, getAsObject(FacesContext context, UIComponent component, String value) and
getAsString(FacesContext context, UIComponent component, Object value) did get called.
According to some other users, the injection works for them. But I am not sure they have
multiple seam modules being used in the same war.
Our war is big and it is difficult to isolate our application to just use seam faces, not
others. So I am not creating a sample war. But it should be easy for seam faces developer
to test this.
I ended up doing bean lookup in my converter and it seems working and the bean is found
in my converter.
public List<T> findBeanRef(FacesContext context, String beanELName) {
BeanManager bm = (BeanManager) (((ServletContext)
context.getExternalContext().getContext())
.getAttribute("org.jboss.seam.faces.javax.enterprise.spi.BeanManager"));
Bean bean = bm.getBeans(beanELName).iterator().next();
CreationalContext ctx = bm.createCreationalContext(bean);
List<T> list = (List<T>) bm.getReference(bean, bean.getClass(),
ctx);
return list;
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: