1 Reply Latest reply on Jul 9, 2009 7:05 AM by Ilya Shaikovsky

    removing an entry from a List

    prerit bhargava Newbie

      i have commandLink that adds user to a datalist on the same webpage.
      when the user is added two buttons are created to delete or mute the user which my application requires.
      the problem is that neither of the two buttons work!!!
      can somebody pls help!!!!

      the home page code is as follows!!!
      Home.xhtml

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <!--
      <ui:define name="body">

      <h1>Incoming SIP Requests</h1>
      <a4j:push id="pushStatus" interval="400" enabled="true"
      eventProducer="#{pushServerMessage.addListener}"
      reRender="dynamicPanel" />

      <rich:panel id="dynamicPanel">
      <h:panelGrid columns="1">
      <s:div styleClass="info">
      <rich:dataList value="#{sharedStore.message}" var="message">
      #{message}
      </rich:dataList>
      </s:div>
      </h:panelGrid>
      </rich:panel>
      </ui:define>
      </ui:composition>
      -->

      <!--Creating Simple Conference Interface -->
      <!--
      <ui:define name="body">

      <h:form id="form">
      <rich:panel>
      <f:facet name="header">
      Ajax Testing
      </f:facet>
      <a4j:commandButton id="createConference" value="Create Conference" action="#{hell.startConference}" binding="#{hell.createConference}"/>


      <h:inputText id="username" /> 
      <a4j:commandLink id="addUser" value="Add User"/>

      </rich:panel>
      </h:form>

      </ui:define>
      </ui:composition>-->

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
      <ui:define name="body">
      <h:form>
      <a4j:commandLink id="conference" binding="#{hell.conference}"
      action="#{hell.startConference}" value="Start Conference"
      rendered="true" reRender="conference,addmembers"
      oncomplete="document.getElementById('addmembers').style.display='block'" />

      <rich:panel style="width:620px;">
      <f:facet name="header">
      <h:outputText value="Add conference members" />
      </f:facet>
      <h:panelGrid columns="2">
      <h:outputText value="Name: " />
      <rich:inplaceInput defaultLabel="Enter a conference name"
      showControls="true" />
      <h:outputText value="Send conference invite to: " />
      <h:inputText id="conferencemember" value="#{hell.member}" />
      <a4j:commandLink id="addmember"
      action="#{hell.addMemberToConference}" value="Add"
      reRender="conferencemember,memberslist"
      oncomplete="document.getElementById('conferencemember').value=''" />
      </h:panelGrid>
      </rich:panel>
      <rich:simpleTogglePanel
      label="List of users currently in conference" switchType="ajax"
      reRender="memberslist">
      <rich:dataTable id="memberslist" value="#{hell.members}" var="mem">
      <rich:column>
      <f:facet name="header"> Member Name </f:facet>
      <h:outputText value="#{mem}" />
      </rich:column>
      <rich:column>
      <f:facet name="header"> Actions </f:facet>
      <a4j:commandLink id="something" rendered="true" value="Remove"
      action="#{hell.removeMember}" />
      <a4j:commandLink value="Mute" action="#{hell.muteMember}" />
      </rich:column>
      </rich:dataTable>
      </rich:simpleTogglePanel>

      </h:form>
      </ui:define>
      </ui:composition>



      Corresponding java file:
      Hell.java

      package org.domain.qwerty.session;

      import java.util.List;
      import java.util.Random;

      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.security.Credentials;
      import org.ajax4jsf.component.html.HtmlAjaxCommandLink;
      import org.apache.log4j.Logger;
      import java.util.ArrayList;

      @Name("hell")
      public class Hell {

      private static Logger logger = Logger.getLogger(Hell.class);

      @In
      Credentials credentials;

      private HtmlAjaxCommandLink conference;
      // private String admin = credentials.getUsername();

      private List members;
      private String member;

      // private HtmlAjaxRegion callerslist;

      public String getMember() {
      return member;
      }

      public void setMember(String member) {
      this.member = member;
      }

      public List getMembers() {
      return members;
      }

      public void setMembers() {
      this.members = new ArrayList();
      }

      public HtmlAjaxCommandLink getConference() {
      if (conference == null)
      conference = new HtmlAjaxCommandLink();
      return conference;
      }

      public void setConference(HtmlAjaxCommandLink conference) {
      this.conference = conference;
      }

      public void startConference() {
      String admin = credentials.getUsername();
      System.out.println("wow");
      conference.setValue("End Conference");
      while (true) {
      Random randomGenerator = new Random();
      Integer dtmf = randomGenerator.nextInt(9);

      logger.info(dtmf + "generated");

      if (ConferenceCenterManager.instance().getConferenceCenter(dtmf) == null) {
      ConferenceCenterManager.instance().setConferenceCenter(dtmf,
      admin);

      /* storing the endpoint name */
      ConferenceCenterManager.instance().getConferenceCenter(dtmf)
      .setConferenceEndPoint(
      "media/trunck/Conference/" + dtmf);

      MapInstanceManager.instance().getMapInstance(admin)
      .setConferenceDtmf(dtmf);

      /* setting the user as admin */

      MapInstanceManager.instance().getMapInstance(admin)
      .setConferenceAdmin(true);
      logger.info("conference initiated");
      break;
      }
      }

      }

      public void addMemberToConference() {

      // logger.info(user + "added to conference");
      logger.info(member + "retrieved");

      String admin = credentials.getUsername();
      ConferenceCenter conferenceCenter = ConferenceCenterManager.instance()
      .getConferenceCenter(
      MapInstanceManager.instance().getMapInstance(admin)
      .getConferenceDtmf());

      conferenceCenter.addConferenceMember(member);
      members = conferenceCenter.getConferenceMembersList();

      member = "";
      for (String temp : members)
      logger.info(temp);

      // conferenceCenter.addConfernceUser(user);
      }

      public void removeMember() {
      logger.info(" to be removed");

      }

      public void muteMember() {
      logger.info("to be muted");
      }
      }

      Thanks!!!!