Ejemplo n.º 1
0
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   String uri = req.getRequestURI();
   if (uri.endsWith("/display")) {
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/redirect")) {
     resp.sendRedirect("servlet/display"); // do a redirect, the cid is not propagated;
   } else if (uri.endsWith("/begin")) {
     conversation.begin();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/end")) {
     conversation.end();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/set")) {
     setMessage(req);
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/invalidateSession")) {
     observer.reset();
     req.getSession().invalidate();
     printInfo(resp.getWriter());
   } else if (uri.endsWith("/listConversationsDestroyedWhileBeingAssociated")) {
     PrintWriter writer = resp.getWriter();
     writer.append("ConversationsDestroyedWhileBeingAssociated: ");
     printSessionIds(writer, observer.getAssociatedConversationIds());
   } else if (uri.endsWith("/listConversationsDestroyedWhileBeingDisassociated")) {
     PrintWriter writer = resp.getWriter();
     writer.append("ConversationsDestroyedWhileBeingDisassociated: ");
     printSessionIds(writer, observer.getDisassociatedConversationIds());
   } else {
     resp.setStatus(404);
   }
   resp.setContentType("text/plain");
 }
Ejemplo n.º 2
0
  public String beginConversation() {
    conversation.begin();
    conversation.setTimeout(500);

    bean.setValue("foo");
    return conversation.getId();
  }
Ejemplo n.º 3
0
 public void beginConversation() {
   if (conversation.isTransient()) {
     System.out.println("beginning conversation : " + this.conversation);
     conversation.begin();
     System.out.println("---> Init Conversation");
   }
 }
Ejemplo n.º 4
0
 public String salvar() {
   cadastroOfertante.cadastrarOfertante(ofertante);
   if (!conversation.isTransient()) {
     conversation.end();
   }
   return "principal?faces-redirect=true";
 }
Ejemplo n.º 5
0
 public void begin() {
   String id = contextManager.getThreadContextId();
   if (id != null) {
     log.debug("Begin conversation:  " + id);
     delegate.begin(id);
   } else {
     delegate.begin();
   }
 }
Ejemplo n.º 6
0
 private void printInfo(PrintWriter writer) {
   writer.append("message: " + message.getValue());
   writer.append("\n");
   writer.append("cid: [" + conversation.getId());
   writer.append("]");
   writer.append("\n");
   writer.append("transient: " + conversation.isTransient());
   writer.append("\n");
 }
  /** Inicializa el bakend bean de control */
  public void initNewObject() {

    if (bandera == Boolean.FALSE) {
      if (conversation.isTransient()) {
        conversation.begin();
      }
      bandera = Boolean.TRUE;
      inicializarVariables();
    }
    busqueda();
  }
  @Override
  public void onUrlMapped(RequestCycle cycle, IRequestHandler handler, Url url) {
    Conversation conversation = container.getCurrentConversation(cycle);

    if (conversation == null || conversation.isTransient()) {
      return;
    }

    if (propagation == ConversationPropagation.ALL) {
      // propagate cid to bookmarkable pages via urls
      url.setQueryParameter(CID, conversation.getId());
    }
  }
  @Override
  public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
    Conversation conversation = container.getCurrentConversation(cycle);

    if (conversation == null) {
      return;
    }

    // propagate a conversation across non-bookmarkable page instances

    Page page = getPage(handler);
    if (!conversation.isTransient() && page != null) {
      page.setMetaData(CID_KEY, conversation.getId());
    }
  }
Ejemplo n.º 10
0
 /**
  * Deletes the customer from the registry
  *
  * @return to showCustomers if the delete was success
  */
 public String action() {
   if (!conv.isTransient()) {
     conv.end();
     Logger.getAnonymousLogger().log(Level.INFO, "CONVERSATION ENDS");
   }
   try {
     String userName = deleteCustomerBackingBean.getUserName();
     customerRegistryBean.remove(userName);
     return "showCustomers?faces-redirect=true"; // Go back
   } catch (Exception e) {
     // Not implemented
     // return "error?faces-redirect=true&cause=" + e.getMessage();
     return null;
   }
 }
Ejemplo n.º 11
0
 public String testConversation() {
   String value = bean.getValue();
   if (!"foo".equals(value)) {
     throw new IllegalStateException("bean's value was not foo");
   }
   return conversation.getId();
 }
Ejemplo n.º 12
0
  public void retrieve() {

    if (FacesContext.getCurrentInstance().isPostback()) {
      return;
    }

    if (conversation.isTransient()) {
      conversation.begin();
    }

    if (id == null) {
      author = example;
    } else {
      author = findById(getId());
    }
  }
Ejemplo n.º 13
0
 public String prepareCreate() {
   conversation.begin();
   if (address == null) {
     address = new Address();
   }
   return "prepare";
 }
Ejemplo n.º 14
0
  /**
   * Prepares the DeleteCustomerBackingBean with data to show which customer the admin is deleting
   *
   * @param ae
   */
  public void actionListener(ActionEvent ae) {
    Customer customer = (Customer) ae.getComponent().getAttributes().get("customer");
    if (conv.isTransient()) {
      conv.begin();
      Logger.getAnonymousLogger()
          .log(Level.INFO, "CONVERSATION BEGINS: Got customer {0}", customer);
    } else {
    }

    deleteCustomerBackingBean.setFname(customer.getFname());
    deleteCustomerBackingBean.setLname(customer.getLname());
    deleteCustomerBackingBean.setEmail(customer.getEmail());
    deleteCustomerBackingBean.setUserName(customer.getUserName());
    Address address;
    address = customer.getAddress();
    deleteCustomerBackingBean.setAddress(address);
  }
Ejemplo n.º 15
0
  @WebRemote
  @Transactional
  public void savePerson() throws Exception {
    if (person.getPersonId() == null) {
      entityManager.persist(person);
    } else {
      person = entityManager.merge(person);
    }

    conversation.end();
  }
Ejemplo n.º 16
0
  @Begin
  public void selectHotel(final Long id) {
    conversation.setTimeout(600000); // 10 * 60 * 1000 (10 minutes)

    // NOTE get a fresh reference that's managed by the extended persistence context
    hotelSelection = em.find(Hotel.class, id);
    if (hotelSelection != null) {
      log.hotelSelected(
          user != null ? user.getName() : "Anonymous",
          hotelSelection.getName(),
          hotelSelection.getCity());
    }
  }
  public void setUsersId(Long usersId) {
    conversation.begin();
    if (usersId != null && usersId.longValue() > 0) { // Verifica que el id no sea vacío
      this.current =
          ejbFacade.find(usersId); // BUsca un paralelo de acuerdo al ID y lo asigna a current
      this.usersId = current.getId();
      System.out.println("Ingreso a editar users: " + current.getUsuario());

    } else {
      System.out.println("Ingreso a crear un nuevo users");
      this.current = new Users();
    }
  }
  public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
    Conversation conversation = container.getCurrentConversation(cycle);

    if (conversation == null || conversation.isTransient()) {
      return;
    }

    // propagate a converastion across non-bookmarkable page instances

    Page page = getPage(handler);
    if (page != null && !conversation.isTransient()) {
      page.setMetaData(CID_KEY, conversation.getId());
    }

    if (propagation == ConversationPropagation.ALL) {
      // propagate cid to a scheduled bookmarkable page

      PageParameters parameters = getPageParameters(handler);
      if (parameters != null) {
        parameters.add(CID, conversation.getId());
      }
    }
  }
Ejemplo n.º 19
0
  // Support updating and deleting Book entities
  public String update() {
    conversation.end();

    try {
      if (id == null) {
        target.request().post(Entity.entity(author, MediaType.APPLICATION_XML));
        return "search?faces-redirect=true";
      } else {
        target.request().put(Entity.entity(author, MediaType.APPLICATION_XML));
        return "view?faces-redirect=true&id=" + author.getId();
      }
    } catch (Exception e) {
      FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
      return null;
    }
  }
Ejemplo n.º 20
0
  public String delete() {
    conversation.end();

    try {

      target
          .path("{id}")
          .resolveTemplate("id", getId())
          .request(MediaType.APPLICATION_XML)
          .delete();

      return "search?faces-redirect=true";
    } catch (Exception e) {
      FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
      return null;
    }
  }
Ejemplo n.º 21
0
 public void conversationEnd() {
   if (!conversation.isTransient()) {
     conversation.end();
   }
 }
Ejemplo n.º 22
0
 public void conversationBegin() {
   if (conversation.isTransient()) {
     conversation.begin();
   }
 }
Ejemplo n.º 23
0
 public String load(Integer id) {
   conversation.begin();
   Long longId = new Long(id + "");
   address = findById(Address.class, longId);
   return "load";
 }
Ejemplo n.º 24
0
 public String create() {
   getEntityManager().joinTransaction();
   getEntityManager().persist(address);
   conversation.end();
   return "create";
 }
Ejemplo n.º 25
0
 public String merge() {
   getEntityManager().joinTransaction();
   getEntityManager().merge(address);
   conversation.end();
   return "merge";
 }
Ejemplo n.º 26
0
 public String cancelar() {
   if (!conversation.isTransient()) {
     conversation.end();
   }
   return "principal?faces-redirect=true";
 }
Ejemplo n.º 27
0
 public void setOfertante(Ofertante ofertante) {
   if (ofertante.getId() != null && conversation.isTransient()) {
     conversation.begin();
   }
   this.ofertante = ofertante;
 }
Ejemplo n.º 28
0
  public String create() {

    conversation.begin();
    return "create?faces-redirect=true";
  }
Ejemplo n.º 29
0
 public void beginConversation() {
   if (conversation.isTransient()) {
     conversation.begin();
     System.out.println("========> INICIANDO CONVERSACION: ");
   }
 }
Ejemplo n.º 30
0
 public void endConversation() {
   if (!conversation.isTransient()) {
     conversation.end();
     System.out.println("========> FINALIZANDO CONVERSACION: ");
   }
 }