Alan Teodoro

Greenhorn
+ Follow
since Jul 14, 2005
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alan Teodoro

I forgot to mention that EmpresaBean.empresa.tipo is List<TipoEmpresa> and that is the way I provide the SelectItems:

private SelectItem[] comboTipoEmpresas = new SelectItem[2];

TipoEmpresa empresa1 = new TipoEmpresa(Long.valueOf(1));
TipoEmpresa empresa2 = new TipoEmpresa(Long.valueOf(2));
getComboTipoEmpresas()[0]= new SelectItem(empresa1,"Produtora");
getComboTipoEmpresas()[1]= new SelectItem(empresa2,"Distribuidora");
16 years ago
JSF
Hello ranchers, please help me to solve this problem:

I created a converter to work with class TipoEmpresa (please see all the code below). The getAsString is working ok, but when I submit the form, I was expecting jsf to call the getAsObject and convert the object again but it is not happening and I get a string instead of TipoEmpresa. Has someone face this problem before ? (EmpresaBean.converter returns the Converter). I also tried other ways to declare the converter and none of them worked)

----JSP----
<h:selectManyListbox styleClass="selectManyMenu"
id="tipo" converter="#{EmpresaBean.converter}" value="#{EmpresaBean.empresa.tipo}" >
<%--<f:converter converterId="TipoEmpresaConverter" />--%>
<f:selectItems value="#{HelperBean.selectItemGroup}"/>
</h:selectManyListbox>

---TipoEmpresa--(variable tipo)./*Accessor methods removed*/
public class TipoEmpresa implements Serializable
{

@Id
@GeneratedValue(strategy = GenerationType.TABLE,generator="SEQ_TIPO_EMPRESA")
private Long id;

private String nome;
private String status;

--Converter--
public class TipoEmpresaConverter implements Converter, Serializable
{
static Logger logger = Logger.getLogger(TipoEmpresaConverter.class);

/** Creates a new instance of TipoEmpresaConvertor */
public TipoEmpresaConverter()
{
logger.debug("Contrutor TipoEmpresaConverter");
}

public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException
{
logger.debug("getAsObject - Object recieved was: " + value + " Type: " + value.getClass().getName());

if(value == null || "".equals(value)){
value = "0";
}

TipoEmpresa tipoEmpresa = new TipoEmpresa(Long.valueOf(value));

return tipoEmpresa;
}

public String getAsString(FacesContext context,
UIComponent component, Object value) throws ConverterException
{

logger.debug("getAsString - Object recieved was: " + value + " Type: " + value.getClass().getName());

if(value == null){
return "";
}
return ((TipoEmpresa)value).getId()+"";
}
}
16 years ago
JSF
Tks everyone for the replies.
17 years ago
I'd like to hear from you guys the best state in USA to go to work with Java, I mean where there are more opportunities for a java developer. I'm going to study but I haven't decided where to go and as I work with java I'd like to go to a place where a can return in the future to look for a opportunitie... Thanks.
17 years ago