def execute(self, mapping, form, request, response): # Extract the Hibernate Session Object servlet = self.getServlet() context = servlet.getServletContext() httpSession = request.getSession() # Removed due to Websphere/Hibernate classloader/classcast issues objFactory = context.getAttribute(HibernateUtilPlugin.KEY_NAME) # We have the needed object, we just need to invoke the factory method # curSess = SimpleAction.invokeVoidContextObject(objFactory, "org.hibernate.SessionFactory", "openSession") curSess = objFactory.openSession() curSess.beginTransaction() # List the links result = curSess.createQuery("from org.spirit.bean.impl.BotListUserLink").list() curSess.getTransaction().commit() httpSession.setAttribute(BotListConsts.BOT_USER_LINKS, result) totl = 0 if result: totl = result.size() linksMsg = "Links Found %s" % totl # Set the confirmation message messages = ActionMessages() msg = ActionMessage("userLink.info.list", linksMsg) messages.add("messageslist", msg) self.saveMessages(request, messages) return mapping.findForward("success")
def execute(self, mapping, form, request, response): # Extract the Hibernate Session Object servlet = self.getServlet() context = servlet.getServletContext() httpSession = request.getSession() # Removed due to Websphere/Hibernate classloader/classcast issues objFactory = context.getAttribute(HibernateUtilPlugin.KEY_NAME) # We have the needed object, we just need to invoke the factory method # curSess = SimpleAction.invokeVoidContextObject(objFactory, "org.hibernate.SessionFactory", "openSession") curSess = objFactory.openSession() curSess.beginTransaction() # List the links result = curSess.createQuery( "from org.spirit.bean.impl.BotListUserLink").list() curSess.getTransaction().commit() httpSession.setAttribute(BotListConsts.BOT_USER_LINKS, result) totl = 0 if result: totl = result.size() linksMsg = "Links Found %s" % totl # Set the confirmation message messages = ActionMessages() msg = ActionMessage("userLink.info.list", linksMsg) messages.add("messageslist", msg) self.saveMessages(request, messages) return mapping.findForward("success")
def execute(self, mapping, form, request, response): # Extract the Hibernate Session Object servlet = self.getServlet() context = servlet.getServletContext() httpSession = request.getSession() curId = request.getParameter("id") print "Link ID=", curId # Removed due to Websphere/Hibernate classloader/classcast issues objFactory = context.getAttribute(HibernateUtilPlugin.KEY_NAME) # We have the needed object, we just need to invoke the factory method # curSess = SimpleAction.invokeVoidContextObject(objFactory, "org.hibernate.SessionFactory", "openSession") curSess = objFactory.openSession() tx = curSess.beginTransaction() # Extract the single entity (long line for query) queryRes = curSess.createQuery("select l from org.spirit.bean.impl.BotListUserLink as l where l.id = :linkid") queryRes.setLong("linkid", Long(curId).longValue()) resLink = queryRes.uniqueResult() httpSession.setAttribute(BotListConsts.BOT_SINGLE_LINK, resLink) tx.commit() linksMsg = "Links Found 1" # Set the confirmation message messages = ActionMessages() msg = ActionMessage("userLink.info.list", linksMsg) messages.add("messagesconfirm", msg) self.saveMessages(request, messages) return mapping.findForward("success")
def execute(self, mapping, form, request, response): # Extract the Hibernate Session Object servlet = self.getServlet() context = servlet.getServletContext() httpSession = request.getSession() curId = request.getParameter("id") print "Link ID=", curId # Removed due to Websphere/Hibernate classloader/classcast issues objFactory = context.getAttribute(HibernateUtilPlugin.KEY_NAME) # We have the needed object, we just need to invoke the factory method # curSess = SimpleAction.invokeVoidContextObject(objFactory, "org.hibernate.SessionFactory", "openSession") curSess = objFactory.openSession() tx = curSess.beginTransaction() # Extract the single entity (long line for query) queryRes = curSess.createQuery( "select l from org.spirit.bean.impl.BotListUserLink as l where l.id = :linkid" ) queryRes.setLong("linkid", Long(curId).longValue()) resLink = queryRes.uniqueResult() httpSession.setAttribute(BotListConsts.BOT_SINGLE_LINK, resLink) tx.commit() linksMsg = "Links Found 1" # Set the confirmation message messages = ActionMessages() msg = ActionMessage("userLink.info.list", linksMsg) messages.add("messagesconfirm", msg) self.saveMessages(request, messages) return mapping.findForward("success")
def execute(self, mapping, form, request, response): print "Execute Simple Struts Action" print "Mapping GetParameter", mapping.getParameter() print "Get Path", mapping.getPath() print "Form Type", dir(form) url = form.url keywords = form.keywords description = form.description # Extract the Hibernate Session Object servlet = self.getServlet() context = servlet.getServletContext() # Removed due to Websphere/Hibernate classloader/classcast issues objFactory = context.getAttribute(HibernateUtilPlugin.KEY_NAME) # We have the needed object, we just need to invoke the factory method # curSess = SimpleAction.invokeVoidContextObject(objFactory, "org.hibernate.SessionFactory", "openSession") curSess = objFactory.openSession() curSess.beginTransaction() link = BotListUserLink() link.mainUrl = url link.description = description link.keywords = keywords curSess.save(link) curSess.getTransaction().commit() # Set the confirmation message messages = ActionMessages() msg = ActionMessage("userLink.info.save", "Data Saved") messages.add("messagesconfirm", msg) self.saveMessages(request, messages) return mapping.findForward("success")