You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by Petr Kotek <ko...@crcdata.cz> on 2007/04/24 15:06:25 UTC

Change value of SelectOneChoice in background

Hello all,

I have next problem with SelectOneChoice component:

1. value is binded to backing bean and taken for example from database
2. when query page, component show correct value
3. now another process change value (in database)
4. page is reloaded (by reload button in browser), then component show 
bad, old value
5. only new query for page show correct value of component

Moreover, if page is submitted (by another component), then bad old 
value of SelectOneChoice component is saved into database.

I am using latest Trinidad 1.0.1 SNAPSHOT.

Thanks for any help,
Peter



I'm simulated this in next test. Changing value by button or 
SelectOneChoice is OK. When I change value of socTestVal in session 
backing bean in debuger (simulating backgroung value change), component 
don't reflect this change, when page is only reloading.

index.jsp test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<f:view>
  <trh:html>
    <trh:head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <title>Select One Choice Test</title>
    </trh:head>
    <trh:body>
      <tr:form id="TestForm">
        <tr:selectOneChoice autoSubmit="true" label="Selection:" 
value="#{IndexBean.socTestValue}">
          <tr:selectItem label="One" value="1"/>
          <tr:selectItem label="Two" value="2"/>
        </tr:selectOneChoice>
        <tr:commandButton text="Set One" 
actionListener="#{IndexBean.ChoiceOneAction}"/>
      </tr:form>
    </trh:body>
  </trh:html>
</f:view>


Session backing bean:

package test.backing;

import javax.faces.event.ActionEvent;

public class IndexBean {
  short socTestVal;
 
  public IndexBean() {
    socTestVal = 2;
  }
 
  public Short getSocTestValue() {
    return socTestVal;
  }
 
  public void setSocTestValue(Short newVal) {
    socTestVal = newVal.shortValue();
  }

  public void ChoiceOneAction(ActionEvent actionEvent) {
     socTestVal = 1;
  }
}




Re: Change value of SelectOneChoice in background

Posted by Petr Kotek <ko...@crcdata.cz>.
Thanks Mike fo response,

but by further investigation I'm founded, that it is bug (or 
"undocumented feature" :) in Firefox. In IE it is all OK.



Mike Kienenberger wrote:
> Maybe this is what you're looking for:
>
> http://www.nabble.com/Re%3A-Programatically-updating-the-model-p9961060.html 
>
>
>
> On 4/24/07, Petr Kotek <ko...@crcdata.cz> wrote:
>> Hello all,
>>
>> I have next problem with SelectOneChoice component:
>>
>> 1. value is binded to backing bean and taken for example from database
>> 2. when query page, component show correct value
>> 3. now another process change value (in database)
>> 4. page is reloaded (by reload button in browser), then component show
>> bad, old value
>> 5. only new query for page show correct value of component
>>
>> Moreover, if page is submitted (by another component), then bad old
>> value of SelectOneChoice component is saved into database.
>>
>> I am using latest Trinidad 1.0.1 SNAPSHOT.
>>
>> Thanks for any help,
>> Peter
>>
>>
>>
>> I'm simulated this in next test. Changing value by button or
>> SelectOneChoice is OK. When I change value of socTestVal in session
>> backing bean in debuger (simulating backgroung value change), component
>> don't reflect this change, when page is only reloading.
>>
>> index.jsp test page:
>>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <%@ page contentType="text/html;charset=UTF-8"%>
>> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
>> <%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
>> <%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
>> <f:view>
>>   <trh:html>
>>     <trh:head>
>>       <meta http-equiv="Content-Type" content="text/html; 
>> charset=UTF-8"/>
>>       <title>Select One Choice Test</title>
>>     </trh:head>
>>     <trh:body>
>>       <tr:form id="TestForm">
>>         <tr:selectOneChoice autoSubmit="true" label="Selection:"
>> value="#{IndexBean.socTestValue}">
>>           <tr:selectItem label="One" value="1"/>
>>           <tr:selectItem label="Two" value="2"/>
>>         </tr:selectOneChoice>
>>         <tr:commandButton text="Set One"
>> actionListener="#{IndexBean.ChoiceOneAction}"/>
>>       </tr:form>
>>     </trh:body>
>>   </trh:html>
>> </f:view>
>>
>>
>> Session backing bean:
>>
>> package test.backing;
>>
>> import javax.faces.event.ActionEvent;
>>
>> public class IndexBean {
>>   short socTestVal;
>>
>>   public IndexBean() {
>>     socTestVal = 2;
>>   }
>>
>>   public Short getSocTestValue() {
>>     return socTestVal;
>>   }
>>
>>   public void setSocTestValue(Short newVal) {
>>     socTestVal = newVal.shortValue();
>>   }
>>
>>   public void ChoiceOneAction(ActionEvent actionEvent) {
>>      socTestVal = 1;
>>   }
>> }
>>

Re: Change value of SelectOneChoice in background

Posted by Mike Kienenberger <mk...@gmail.com>.
Maybe this is what you're looking for:

http://www.nabble.com/Re%3A-Programatically-updating-the-model-p9961060.html


On 4/24/07, Petr Kotek <ko...@crcdata.cz> wrote:
> Hello all,
>
> I have next problem with SelectOneChoice component:
>
> 1. value is binded to backing bean and taken for example from database
> 2. when query page, component show correct value
> 3. now another process change value (in database)
> 4. page is reloaded (by reload button in browser), then component show
> bad, old value
> 5. only new query for page show correct value of component
>
> Moreover, if page is submitted (by another component), then bad old
> value of SelectOneChoice component is saved into database.
>
> I am using latest Trinidad 1.0.1 SNAPSHOT.
>
> Thanks for any help,
> Peter
>
>
>
> I'm simulated this in next test. Changing value by button or
> SelectOneChoice is OK. When I change value of socTestVal in session
> backing bean in debuger (simulating backgroung value change), component
> don't reflect this change, when page is only reloading.
>
> index.jsp test page:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <%@ page contentType="text/html;charset=UTF-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
> <%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
> <f:view>
>   <trh:html>
>     <trh:head>
>       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
>       <title>Select One Choice Test</title>
>     </trh:head>
>     <trh:body>
>       <tr:form id="TestForm">
>         <tr:selectOneChoice autoSubmit="true" label="Selection:"
> value="#{IndexBean.socTestValue}">
>           <tr:selectItem label="One" value="1"/>
>           <tr:selectItem label="Two" value="2"/>
>         </tr:selectOneChoice>
>         <tr:commandButton text="Set One"
> actionListener="#{IndexBean.ChoiceOneAction}"/>
>       </tr:form>
>     </trh:body>
>   </trh:html>
> </f:view>
>
>
> Session backing bean:
>
> package test.backing;
>
> import javax.faces.event.ActionEvent;
>
> public class IndexBean {
>   short socTestVal;
>
>   public IndexBean() {
>     socTestVal = 2;
>   }
>
>   public Short getSocTestValue() {
>     return socTestVal;
>   }
>
>   public void setSocTestValue(Short newVal) {
>     socTestVal = newVal.shortValue();
>   }
>
>   public void ChoiceOneAction(ActionEvent actionEvent) {
>      socTestVal = 1;
>   }
> }
>
>
>
>