UPDATE_MODEL_VALUES phase is setting object to default value (e.g. BigDecimal = 
0, Integer = 0)
-----------------------------------------------------------------------------------------------

                 Key: MYFACES-2199
                 URL: https://issues.apache.org/jira/browse/MYFACES-2199
             Project: MyFaces Core
          Issue Type: Bug
    Affects Versions: 1.2.6
         Environment: Web Application: MyFaces 1.2.6, Tomahawk12 1.1.8, 
Richfaces 3.3.0, Facelets 1.1.14
Application Server: Tomcat 6.0.18
IDE : Eclipse 3.4.2
            Reporter: Himanshu Amin


I have following in my JSP
<h:inputText id="bigDecimal" value="#{myHandler.bigDecimal}" size="11" 
maxlength="50"   converter="CustomBigDecimalConverter"/>

I have following in my CustomBigDecimalConverter. Which is returning null if 
you leave input text empty.
        public Object getAsObject(FacesContext arg0, UIComponent arg1, String 
arg2)throws ConverterException{
                try {
                        if(arg2 != null){
                                String localS = arg2.toString().trim();
                                if(StringUtils.isNotBlank(localS)){
                                        BigDecimal bigDecimal = new 
BigDecimal(localS);
                                        return bigDecimal;
                                }
                        }
                        return null;
                } catch (Exception e) {
                        FacesMessage msg = new FacesMessage();
                        msg.setSummary("Please enter a valid Amount. Alphabet 
and negative value is not allowed.");     
                        throw new ConverterException(msg);
                }
        }
Following I have in my Phase Listener. I am calling this code on before and 
after.
        private void myTesting(PhaseEvent phaseEvent) {
                try{
                        MyHandler MyHandler= (MyHandler) 
FacesUtils.getManagedBean("MyHandler");
                        if(MyHandler!= null){
                                System.out.println("My Handler : "+MyHandler);
                                if(MyHandler.getBigDecimal() != null){
                                        System.out.println("BigDecimal : 
"+MyHandler.getBigDecimal());  
                                }
                        }
                }catch (Exception e) {
                        e.printStackTrace();
                }
        }

Following is my Out put of Phase Listener
BEFORE PHASE : RESTORE_VIEW(1)
My Handler : xxx.myhand...@126078f
AFTER PHASE : RESTORE_VIEW(1)
My Handler : xxx.myhand...@126078f
BEFORE PHASE : APPLY_REQUEST_VALUES(2)
My Handler : xxx.myhand...@126078f
AFTER PHASE : APPLY_REQUEST_VALUES(2)
My Handler : xxx.myhand...@126078f
BEFORE PHASE : PROCESS_VALIDATIONS(3)
My Handler : xxx.myhand...@126078f
AFTER PHASE : PROCESS_VALIDATIONS(3)
My Handler : xxx.myhand...@126078f
BEFORE PHASE : UPDATE_MODEL_VALUES(4)
My Handler : xxx.myhand...@126078f
AFTER PHASE : UPDATE_MODEL_VALUES(4)
My Handler : xxx.myhand...@126078f
BigDecimal : 0
BEFORE PHASE : INVOKE_APPLICATION(5)
My Handler : xxx.myhand...@126078f
BigDecimal : 0
AFTER PHASE : INVOKE_APPLICATION(5)
My Handler : xxx.myhand...@126078f
BigDecimal : 0
BEFORE PHASE : RENDER_RESPONSE(6)
My Handler : xxx.myhand...@126078f
BigDecimal : 0
AFTER PHASE : RENDER_RESPONSE(6)
My Handler : xxx.myhand...@126078f
BigDecimal : 0

If we see in above log, I can see BigDecimal's value was null until BEFORE 
PHASE : UPDATE_MODEL_VALUES(4). It became "0" on and after AFTER PHASE : 
UPDATE_MODEL_VALUES(4). 
I am facing this problem in MyFaces 1.2. Earlier I was using same code with 
MyFaces 1.1 and it was/is running fine. So I thought I should let you know.
Please let me know if I am doing something wrong here as I am really newbie. 
Please let me know if I can help in anything with this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to