Hello,
My page contains a persistent byte property which is used as the value
in Property Selection.
The persistent value is assigned inside pageBeginRender. During
debugging I can see the property being assigned a value other then
one. After the render the property selection always shows the first
item as being selected. I've spent hours looking at this. Can anybody
provide any clues?

Page class extract

@Persist
public abstract byte getLoggingRate();
public abstract void setLoggingRate(byte b);

public LoggingRateSelectionModel getLoggingRateSelectionModel(){
      return new LoggingRateSelectionModel();
}

public void pageBeginRender(PageEvent pageEvent){


     if (!pageEvent.getRequestCycle().isRewinding()){

// if doing a render and the channel list is empty then obtain a new
channel list and persist.
if ((getChannelSetup()==null)||(getChannelSetup().size()==0)){
    try {
         refreshCelloPagesSettings();
     } catch (Exception e) {
        e.printStackTrace();
                                }

     }
                        System.out.println("rendering");
                } else {
                        System.out.println("rewinding");
                }
        }


public void refreshCelloPagesSettings(){
Cello6 cello6=null;
  try {
    cello6 = getCello6DAO().get(getCelloSerialNumber());
   } catch (SQLException e1) {
       e1.printStackTrace();
    } catch (Exception e1) {
       e1.printStackTrace();
    }

   if (cello6==null) return;

   setChannelSetup(getCello6DAO().getChannelSetup(getCelloSerialNumber()));
   setBatteryAlarm(getCello6().isBatteryAlarm());
   byte rate = (byte)cello6.getLoggingRate();
   setLoggingRate(rate);
}

page.page file
<component id="loggingRate" type="PropertySelection">
   <binding name="model" value="loggingRateSelectionModel"/>
   <binding name="value" value="loggingRate"/>
</component>

page.html file

<table>

                                                        
<tr><td class="Cello6DetailsChannelPropertyTitle" nowrap>Logging Rate</td>
   <td class="Cello6DetailsChannelPropertyValue"><input
jwcid="loggingRate" type="text"/></td>
</tr>
<tr><td colspan="4">
        <input type="Submit" value="Update" jwcid="@Submit"
action="listener:doUpdateChannelDataAndInfo"
ognl:!updateChannelDataAndInfo"/> &nbsp; <div class="warning"
jwcid="@Insert" value="ognl:dataMessage"/></td>
</tr>
                                                
propertyselection model  source
public class LoggingRateSelectionModel implements IPropertySelectionModel {

               public static Map<String, Short> rate = new
LinkedHashMap<String, Short>();

        static {
                rate.put("1 minute", (short)1);
                rate.put("2 minutes", (short)2);
                rate.put("3 minutes",(short)3);
                rate.put("4 minutes",(short)4);
                rate.put("5 minutes", (short)5);
                rate.put("6 minutes", (short)6);
                rate.put("10 minutes", (short)10);
                rate.put("12 minutes", (short)12);
                rate.put("15 minutes", (short)15);
                rate.put("20 minutes", (short)20);
                rate.put("30 minutes", (short)30);
                rate.put("1 hour", (short)60);
        }

        public int getOptionCount() {
                return rate.size();
        }

        public Object getOption(int index) {
                Short[] values = rate.values().toArray(new Short[0]);

                return values[index];
        }

        public String getLabel(int index) {
                String[] keys = rate.keySet().toArray(new String[0]);
                return keys[index];
        }

        public String getValue(int index) {
                return Integer.toString(index);
        }

        public Object translateValue(String value) {
                Short[] values = rate.values().toArray(new Short[0]);
                return new Short(values[Integer.parseInt(value)]);
        }

}

--
Thanks

A Jabbar Azam

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to