Re: Readonly + Validator
I can't reproduce this behavior. Can you please provide a small example showing this problem? Regards, Volker 2007/8/16, daniel ccss [EMAIL PROTECTED]: I think is a bug, is the only value that becomes 0 when a readonly property is set to true On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Let me summarize: You have a datatable with rows containing commandLinks with parameters. in a actionListener you fetch the parameter and set the bean value to 21. Then a readonly selectOneMenu is rendered and after receiving the request the bean value is resetted to 0. In this case there must be a bug in the selectOneMenu component. Can you put a debug statement with stacktrace in the setter to find out from where the value is set to 0? Regards, Volker 2007/8/16, daniel ccss [EMAIL PROTECTED]: The value before is 21, the only problem is that when I put it readonly I can´t access his value and recived a 0. I have a datatable and in each row i of the datatable I have a commandLink to edit, when I click on the edit link I fill the form in an action listener that will be edit (look for the bold text), then I show the jsp: public void establecerFormEditar(ActionEvent event){ //Se obtiene el parámetro del día UIParameter parametro = (UIParameter)event.getComponent().findComponent(parDia); this.parDia = Integer.parseInt (parametro.getValue().toString()); //Se obtiene el parámetro del mes parametro = (UIParameter)event.getComponent().findComponent(parMes); this.parMes = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del anio parametro = (UIParameter)event.getComponent().findComponent(parAnio); this.parAnio = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del motivo parametro = (UIParameter)event.getComponent().findComponent(dscFeriado); this.dscFeriado = parametro.getValue().toString(); //Se obtiene el parámetro del logAplicaSiempre parametro = (UIParameter)event.getComponent().findComponent(logAplicaSiempre); this.logAplicaSiempre = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del tipFeriado parametro = (UIParameter)event.getComponent().findComponent(tipFeriado); this.tipFeriado = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del logActivo parametro = (UIParameter)event.getComponent().findComponent(logActivo); this.logActivo = Integer.parseInt(parametro.getValue().toString()); } On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Which value has getTipFeriado() BEFORE rendering the html to the Browser? Why did you expect this is changed to the value displayed in the Browser? 2007/8/16, daniel ccss [EMAIL PROTECTED]: The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size =1 disabled= disabled option value =21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value= 15POR DESATRES NATURALES/option option value=62 BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size=1 disabled=disabled option value=21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value=15POR DESATRES NATURALES/option option value=62BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
Which value has getTipFeriado() BEFORE rendering the html to the Browser? Why did you expect this is changed to the value displayed in the Browser? 2007/8/16, daniel ccss [EMAIL PROTECTED]: The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size =1 disabled= disabled option value =21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value= 15POR DESATRES NATURALES/option option value=62 BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
The value before is 21, the only problem is that when I put it readonly I can´t access his value and recived a 0. I have a datatable and in each row i of the datatable I have a commandLink to edit, when I click on the edit link I fill the form in an action listener that will be edit (look for the bold text), then I show the jsp: public void establecerFormEditar(ActionEvent event){ //Se obtiene el parámetro del día UIParameter parametro = (UIParameter)event.getComponent().findComponent(parDia); this.parDia = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del mes parametro = (UIParameter)event.getComponent().findComponent(parMes); this.parMes = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del anio parametro = (UIParameter)event.getComponent().findComponent(parAnio); this.parAnio = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del motivo parametro = (UIParameter)event.getComponent().findComponent(dscFeriado); this.dscFeriado = parametro.getValue().toString(); //Se obtiene el parámetro del logAplicaSiempre parametro = (UIParameter)event.getComponent().findComponent(logAplicaSiempre); this.logAplicaSiempre = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del tipFeriado parametro = (UIParameter)event.getComponent().findComponent(tipFeriado); this.tipFeriado = Integer.parseInt(parametro.getValue ().toString()); //Se obtiene el parámetro del logActivo parametro = (UIParameter)event.getComponent().findComponent(logActivo); this.logActivo = Integer.parseInt(parametro.getValue().toString()); } On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Which value has getTipFeriado() BEFORE rendering the html to the Browser? Why did you expect this is changed to the value displayed in the Browser? 2007/8/16, daniel ccss [EMAIL PROTECTED]: The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size =1 disabled= disabled option value =21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value= 15POR DESATRES NATURALES/option option value=62 BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
Let me summarize: You have a datatable with rows containing commandLinks with parameters. in a actionListener you fetch the parameter and set the bean value to 21. Then a readonly selectOneMenu is rendered and after receiving the request the bean value is resetted to 0. In this case there must be a bug in the selectOneMenu component. Can you put a debug statement with stacktrace in the setter to find out from where the value is set to 0? Regards, Volker 2007/8/16, daniel ccss [EMAIL PROTECTED]: The value before is 21, the only problem is that when I put it readonly I can´t access his value and recived a 0. I have a datatable and in each row i of the datatable I have a commandLink to edit, when I click on the edit link I fill the form in an action listener that will be edit (look for the bold text), then I show the jsp: public void establecerFormEditar(ActionEvent event){ //Se obtiene el parámetro del día UIParameter parametro = (UIParameter)event.getComponent().findComponent(parDia); this.parDia = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del mes parametro = (UIParameter)event.getComponent().findComponent(parMes); this.parMes = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del anio parametro = (UIParameter)event.getComponent().findComponent(parAnio); this.parAnio = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del motivo parametro = (UIParameter)event.getComponent().findComponent(dscFeriado); this.dscFeriado = parametro.getValue().toString(); //Se obtiene el parámetro del logAplicaSiempre parametro = (UIParameter)event.getComponent().findComponent(logAplicaSiempre); this.logAplicaSiempre = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del tipFeriado parametro = (UIParameter)event.getComponent().findComponent(tipFeriado); this.tipFeriado = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del logActivo parametro = (UIParameter)event.getComponent().findComponent(logActivo); this.logActivo = Integer.parseInt(parametro.getValue().toString()); } On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Which value has getTipFeriado() BEFORE rendering the html to the Browser? Why did you expect this is changed to the value displayed in the Browser? 2007/8/16, daniel ccss [EMAIL PROTECTED]: The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size =1 disabled= disabled option value =21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value= 15POR DESATRES NATURALES/option option value=62 BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
I think is a bug, is the only value that becomes 0 when a readonly property is set to true On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Let me summarize: You have a datatable with rows containing commandLinks with parameters. in a actionListener you fetch the parameter and set the bean value to 21. Then a readonly selectOneMenu is rendered and after receiving the request the bean value is resetted to 0. In this case there must be a bug in the selectOneMenu component. Can you put a debug statement with stacktrace in the setter to find out from where the value is set to 0? Regards, Volker 2007/8/16, daniel ccss [EMAIL PROTECTED]: The value before is 21, the only problem is that when I put it readonly I can´t access his value and recived a 0. I have a datatable and in each row i of the datatable I have a commandLink to edit, when I click on the edit link I fill the form in an action listener that will be edit (look for the bold text), then I show the jsp: public void establecerFormEditar(ActionEvent event){ //Se obtiene el parámetro del día UIParameter parametro = (UIParameter)event.getComponent().findComponent(parDia); this.parDia = Integer.parseInt(parametro.getValue ().toString()); //Se obtiene el parámetro del mes parametro = (UIParameter)event.getComponent().findComponent(parMes); this.parMes = Integer.parseInt(parametro.getValue ().toString()); //Se obtiene el parámetro del anio parametro = (UIParameter)event.getComponent().findComponent(parAnio); this.parAnio = Integer.parseInt(parametro.getValue ().toString()); //Se obtiene el parámetro del motivo parametro = (UIParameter)event.getComponent().findComponent(dscFeriado); this.dscFeriado = parametro.getValue().toString(); //Se obtiene el parámetro del logAplicaSiempre parametro = (UIParameter)event.getComponent().findComponent(logAplicaSiempre); this.logAplicaSiempre = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del tipFeriado parametro = (UIParameter)event.getComponent().findComponent(tipFeriado); this.tipFeriado = Integer.parseInt(parametro.getValue().toString()); //Se obtiene el parámetro del logActivo parametro = (UIParameter)event.getComponent().findComponent(logActivo); this.logActivo = Integer.parseInt(parametro.getValue ().toString()); } On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Which value has getTipFeriado() BEFORE rendering the html to the Browser? Why did you expect this is changed to the value displayed in the Browser? 2007/8/16, daniel ccss [EMAIL PROTECTED]: The scope is session, If i see the page source code from the browser I get this, as you see the 21 is the first value, but it brings me a 0 if is read only. What I just notice is that in the JSP I have readonly=true and in this source code I see: disabled=disabled is that right?? Again if I erase the readonly=true I get the correct value 21: select name=agregarDiaFeriadoForm:_idJsp12 size =1 disabled= disabled option value =21RELIGIOSO/option option value=1DEL ESTADO/option option value=2POR VACACIONES/option option value=3PATRONALES/option option value= 15POR DESATRES NATURALES/option option value=62 BE/option/select On 8/16/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, is the value of getTipFeriado() truely 21 BEFORE rendering the page? Which scope is the bean? Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: On a readonly component the model value will not change! I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).
Re: Readonly + Validator
Hello Daniel, What you want to do is not the responsibility of validators, but converter's. What you need is a simple converter that will do a .toUpperCase() in getAsObject(). However, if you want to respect the inverse property of getAsObject() vs. getAsString() you'll have to also use toUpperCase() in getAsString() and also make sure that your bean always contains an uppercase default value (or null). Regards, ~ Simon On 8/15/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, i don't understand the first question. You can use getTipFeriado() on the bean instance independent of the readonly status of the ui component. When the ui component is readonly the value will not change. for the second question try: ((EditableValueHolder)uiComponent).setSubmittedValue( uiComponent.getSubmittedValue().toUpperCase()) in your validate method. Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: Hi all, I have 2 questions: Question1: In my JSP I have: td class=td-contenido colspan=2 h:selectOneMenu value=#{DiaFeriadoBean.tipFeriado } readonly=true f:selectItems value=#{DiaFeriadoBean.tiposFeriadosSelect} / /h:selectOneMenu /td . And In the DiaFeriadoBean the value of tipFeriado property is 0, I tried with disabled = true, but is the same, If I quit the reaonly=true then I can get the value, My question is how can I get the value of a property that is read only? Question2: I use custom validators, and I need one to pass the value that the user enter to UpperCase: public class TextValidator implements Validator { . public void validate(FacesContext facesContext, UIComponent uIComponent, Object value) throws ValidatorException{ ... What I need is that in this validate method change the value of the component to UpperCase, I have a javascript to do that, but I also want to have it on a validator method, how can I set the value of the component to the same value but toUpperCase something like uIComponent = value.toUpperCase. Regards, Daniel
Re: Readonly + Validator
Thanks!!! 1- When the select have the attribute of readonly in true when i use getTipFeriado() I get a 0 value, when i put it in false I get 21 (the correct value), this is the select: h:selectOneMenu value=#{ DiaFeriadoBean.tipFeriado} f:selectItems value=#{ DiaFeriadoBean.tiposFeriadosSelect} / /h:selectOneMenu 2- I have somenthing very similar but it dosn´t works: String valor = (String)value; ((EditableValueHolder)uIComponent).setSubmittedValue(value.toUpperCase()) It change the value but when i get back to the bean it steal have the value in lowercase I use your code, but a I recived a Sintaxis error: getSubmittedValue not found, do I have to do another cast: ((EditableValueHolder)uIComponent).setSubmittedValue(uIComponent.* getSubmittedValue*().toUpperCase())
Re: Readonly + Validator
Do you have an example? I never have use a converter, is code in the JSP? What about the second question, do you know how to do it? On 8/15/07, Simon Lessard [EMAIL PROTECTED] wrote: Hello Daniel, What you want to do is not the responsibility of validators, but converter's. What you need is a simple converter that will do a .toUpperCase() in getAsObject(). However, if you want to respect the inverse property of getAsObject() vs. getAsString() you'll have to also use toUpperCase() in getAsString() and also make sure that your bean always contains an uppercase default value (or null). Regards, ~ Simon On 8/15/07, Volker Weber [EMAIL PROTECTED] wrote: Hi, i don't understand the first question. You can use getTipFeriado() on the bean instance independent of the readonly status of the ui component. When the ui component is readonly the value will not change. for the second question try: ((EditableValueHolder)uiComponent).setSubmittedValue( uiComponent.getSubmittedValue().toUpperCase()) in your validate method. Regards, Volker 2007/8/15, daniel ccss [EMAIL PROTECTED]: Hi all, I have 2 questions: Question1: In my JSP I have: td class=td-contenido colspan=2 h:selectOneMenu value=#{DiaFeriadoBean.tipFeriado } readonly=true f:selectItems value=#{ DiaFeriadoBean.tiposFeriadosSelect} / /h:selectOneMenu /td . And In the DiaFeriadoBean the value of tipFeriado property is 0, I tried with disabled = true, but is the same, If I quit the reaonly=true then I can get the value, My question is how can I get the value of a property that is read only? Question2: I use custom validators, and I need one to pass the value that the user enter to UpperCase: public class TextValidator implements Validator { . public void validate(FacesContext facesContext, UIComponent uIComponent, Object value) throws ValidatorException{ ... What I need is that in this validate method change the value of the component to UpperCase, I have a javascript to do that, but I also want to have it on a validator method, how can I set the value of the component to the same value but toUpperCase something like uIComponent = value.toUpperCase. Regards, Daniel
Re: Readonly + Validator
*On a readonly component the model value will not change! * I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value). attachment: readonly.gif
Re: Readonly + Validator
Thanks for the Converter tip, i succesfully implemented it =) On 8/15/07, daniel ccss [EMAIL PROTECTED] wrote: *On a readonly component the model value will not change! * I know, I try to explain my point better with an image, as you can see when I load the edit form the select have a value selected readOnly, the code of the value selected is 21. Ok then I modify some others value and click on the h:commandLink when in my backing_bean I get the value of the selected code in the select if (when the select is readonly) is 0! If I modify the jsp code and put readonly=false, in the backing_bean i get a 21 (correct value).