webtier@glassfish.java.net

Re: JSF conversion+inconsistency issue

From: <webtier_at_javadesktop.org>
Date: Mon, 31 Aug 2009 08:49:40 PDT

I had put together a trimmed down version of my production code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
</h:head>

<h:body>
        <h:form id="form">
        
                <h:messages/>
        
                <h:selectOneRadio id="rbSwitch" value="#{testBean.goods}" valueChangeListener="#{testBean.rbChanged}" onclick="submit();">
                        <f:selectItem itemLabel="#{msgs.goods}" itemValue="1" />
                        <f:selectItem itemLabel="#{msgs.service}" itemValue="0" />
                </h:selectOneRadio>
                
                <h:inputText value="#{testBean.sampleValue}"/>

        </h:form>

</h:body>

</html>



package beszterv.view;

import java.math.BigDecimal;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.PhaseId;
import javax.faces.event.ValueChangeEvent;

@ManagedBean
@RequestScoped
public class TestBean {
        
        private int goods;
        private BigDecimal sampleValue;

        public int getGoods() {
                return goods;
        }

        public void setGoods(int goods) {
                this.goods = goods;
        }

        public BigDecimal getSampleValue() {
                return sampleValue;
        }

        public void setSampleValue(BigDecimal sampleValue) {
                this.sampleValue = sampleValue;
        }
        
        public void rbChanged(ValueChangeEvent event) {
                if (event.getPhaseId().equals(PhaseId.ANY_PHASE)) {
                        event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
                        event.queue();
                        return;
                }
                
                System.out.println("conversion passed");
        }

        @PostConstruct
        public void init() {

        }

}
[Message sent by forum member 'gabox01' (beres.gabor_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=362437