2 Replies Latest reply on Sep 14, 2009 6:58 AM by JLuis -

    a4j:repeat and f:setPropertyActionListener

    JLuis - Newbie

      Does somebody know how to fix this sample code?
      Several tries of my own didn't help.
      I am trying to learn how a4j:repeat and f:setPropertyActionListener could work together.
      Thanks!

      <table>
       <a4j:repeat value="#{channelViewBean.channels}" var="channel">
       <tr>
       <td>
       <h:commandLink value="Select">
       <f:setPropertyActionListener value="#{channel}"
       target="#{channelViewBean.selectedChannel}" />
       </h:commandLink>
       </td>
       <td>
       #{channel.name}
       </td>
       </tr>
       </a4j:repeat>
      </table>
      
      <h:outputText value="#{channelViewBean.selectedChannel.number}" />
      


      public class ChannelViewBean {
      
       private List<ChannelBean> channels;
       private ChannelBean selectedChannel;
      
       public ChannelViewBean() {
       channels = new ArrayList<ChannelBean>();
       channels.add(new ChannelBean("1", "TVE1"));
       channels.add(new ChannelBean("2", "TVE2"));
       channels.add(new ChannelBean("3", "A3"));
       channels.add(new ChannelBean("4", "CUATRO"));
       channels.add(new ChannelBean("5", "Tele5"));
       }
      
       public void setSelectedChannel(ChannelBean selectedChannel) {
       this.selectedChannel = selectedChannel;
       }
      
       public ChannelBean getSelectedChannel() {
       return selectedChannel;
       }
      
       public void setChannels(List<ChannelBean> channels) {
       this.channels = channels;
       }
      
       public List<ChannelBean> getChannels() {
       return channels;
       }
      
      }
      


      public class ChannelBean {
      
       private String number = "";
       private String name = "";
      
       public ChannelBean(String number, String name) {
       this.number = number;
       this.name = name;
       }
      
       public void setNumber(String number) {
       this.number = number;
       }
      
       public String getNumber() {
       return number;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       public String getName() {
       return name;
       }
      
      }