@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"); }
public String beginConversation() { conversation.begin(); conversation.setTimeout(500); bean.setValue("foo"); return conversation.getId(); }
public void beginConversation() { if (conversation.isTransient()) { System.out.println("beginning conversation : " + this.conversation); conversation.begin(); System.out.println("---> Init Conversation"); } }
public String salvar() { cadastroOfertante.cadastrarOfertante(ofertante); if (!conversation.isTransient()) { conversation.end(); } return "principal?faces-redirect=true"; }
public void begin() { String id = contextManager.getThreadContextId(); if (id != null) { log.debug("Begin conversation: " + id); delegate.begin(id); } else { delegate.begin(); } }
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()); } }
/** * 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; } }
public String testConversation() { String value = bean.getValue(); if (!"foo".equals(value)) { throw new IllegalStateException("bean's value was not foo"); } return conversation.getId(); }
public void retrieve() { if (FacesContext.getCurrentInstance().isPostback()) { return; } if (conversation.isTransient()) { conversation.begin(); } if (id == null) { author = example; } else { author = findById(getId()); } }
public String prepareCreate() { conversation.begin(); if (address == null) { address = new Address(); } return "prepare"; }
/** * 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); }
@WebRemote @Transactional public void savePerson() throws Exception { if (person.getPersonId() == null) { entityManager.persist(person); } else { person = entityManager.merge(person); } conversation.end(); }
@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()); } } }
// 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; } }
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; } }
public void conversationEnd() { if (!conversation.isTransient()) { conversation.end(); } }
public void conversationBegin() { if (conversation.isTransient()) { conversation.begin(); } }
public String load(Integer id) { conversation.begin(); Long longId = new Long(id + ""); address = findById(Address.class, longId); return "load"; }
public String create() { getEntityManager().joinTransaction(); getEntityManager().persist(address); conversation.end(); return "create"; }
public String merge() { getEntityManager().joinTransaction(); getEntityManager().merge(address); conversation.end(); return "merge"; }
public String cancelar() { if (!conversation.isTransient()) { conversation.end(); } return "principal?faces-redirect=true"; }
public void setOfertante(Ofertante ofertante) { if (ofertante.getId() != null && conversation.isTransient()) { conversation.begin(); } this.ofertante = ofertante; }
public String create() { conversation.begin(); return "create?faces-redirect=true"; }
public void beginConversation() { if (conversation.isTransient()) { conversation.begin(); System.out.println("========> INICIANDO CONVERSACION: "); } }
public void endConversation() { if (!conversation.isTransient()) { conversation.end(); System.out.println("========> FINALIZANDO CONVERSACION: "); } }