1 6 7 package org.exoplatform.portlets.weather.component; 8 9 import java.util.ArrayList ; 10 import org.exoplatform.faces.core.component.*; 11 import org.exoplatform.faces.core.component.model.*; 12 13 14 import com.capeclear.www.GlobalWeather_xsd.*; 15 16 public class UISelectStationForm extends UISimpleForm 17 { 18 private String selectStationCode_; 19 private Station [] stationsList_; 20 private UISelectBox uiSelectBox_; 21 22 public UISelectStationForm() { 23 super("selectStationForm", "post", null); 24 setId("UISelectStationForm"); 25 26 uiSelectBox_ = new UISelectBox("UISelectBox","",null); 27 updateTree(); 28 } 29 30 public String getSelectStationCode() { 31 if (uiSelectBox_ != null) return uiSelectBox_.getValue(); 32 else return null; 33 } 34 35 public void setStationsList(Station [] pStationsList) { 36 stationsList_ = pStationsList; 37 updateTree(); 38 } 39 40 private void updateTree() { 41 clear(); 42 if (stationsList_ != null) { 43 ArrayList liste = new ArrayList (); 44 for (int i = 0; i < stationsList_.length; i++) 45 { 46 String nomStation = stationsList_[i].getName(); 47 String codeStation = stationsList_[i].getIcao(); 48 if (codeStation == null) codeStation = stationsList_[i].getIata(); 49 String paysStation = stationsList_[i].getCountry(); 50 liste.add(new SelectItem(nomStation+" ("+paysStation+")",codeStation)); 51 } 52 String defaultCode = stationsList_[0].getIcao(); 53 if (defaultCode == null) defaultCode = stationsList_[0].getIata(); 54 uiSelectBox_.setValue(defaultCode); 55 uiSelectBox_.setOptions(liste); 56 add(new Row(). 57 add(new ComponentCell(this, uiSelectBox_))); 58 } 59 60 add(new Row(). 61 add(new ListComponentCell(). 62 add(new FormButton("OK","SelectStationFormOk")). 63 addColspan("2").addAlign("center"))); 64 } 65 } 66 | Popular Tags |