[jboss-user] [JBoss Seam] - getAsObject not being called - why?

X490812 do-not-reply at jboss.com
Wed Dec 19 18:10:58 EST 2007


here is the converter:
@Name("tst")
  | @Scope(ScopeType.APPLICATION)
  | @org.jboss.seam.annotations.faces.Converter(id="tst")
  | public class Tst implements Converter {
  | 
  | 	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
  | 		int i = 0;
  | 		return (arg2 == null || arg2.equals("") || arg2.equals("0") ||  arg2.equals("false") ? new BigDecimal(0) : new BigDecimal(1));
  | 	}
  | 
  | 	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
  | 		if (arg2 instanceof Boolean)
  | 		{
  | 			return (arg2 == null || ((Boolean)arg2).equals(false) ? "N" : "Y");
  | 		}
  | 		else
  | 			return (arg2 == null || ((BigDecimal)arg2).intValue() == 0 ? "false" : "true");
  | 	}
  | 
  | }

Here is the xhtml:

  | <html xmlns="http://www.w3.org/1999/xhtml"
  | 	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	xmlns:ui="http://java.sun.com/jsf/facelets"
  | 	xmlns:f="http://java.sun.com/jsf/core"
  | 	xmlns:h="http://java.sun.com/jsf/html"
  | 	xmlns:a4j="http://richfaces.org/a4j"
  | 	xmlns:rich="http://richfaces.ajax4jsf.org/rich">
  | 
  | <link
  | 	href="stylesheet/fraud.css"
  | 	rel="stylesheet"
  | 	type="text/css" />
  | <h:messages
  | 	globalOnly="true"
  | 	styleClass="message"
  | 	id="globalMessages" />
  | <h:form id="caseDetailForm">
  | 	<br />
  | .
  | .
  | <td class="data">
  | 				<h:selectBooleanCheckbox 
  | 					id="hotTask" 
  | 					value="#{selectedCase.basedonhottask}"
  | 					converter="tst">
  | 				</h:selectBooleanCheckbox>
  | 			</td>
  | 
In my backing bean, the field basedonhottask is a BigDecimal and my converter should convert it to and from Boolean to BigDecimal. 

The proble is that upon render, it calls getAsString to convert from BigDecmal to the strings "false" or "true" depending on whether BigDecimal is 0 or 1 - and that seems to work fine - the checkbox is populated correctly. BUT, after changing the checkbox, on submit, it NEVER calls getAsObject - it calls getAsString again - dont know why??? Shouldnt it calls getAsObject to convert the BooleanCheckbos back into a BigDecimal?
If this is a bug, is there a workaround?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114446#4114446

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114446



More information about the jboss-user mailing list