Model Data MVC Stripes

I have experience with Spring MVC and am trying to run Stripes to decide whether to try it for a new project.

In Spring MVC, I would prepare the model data and pass it into the view by adding it to the map in the ModelAndView instance created by my controller. I find it hard to find the equivalent of this for Stripes.

It seems that the closest parallel is for ActionBean to prepare my model data and add it to the HttpSession. ForwardRedirect is used to load views and access data from a session.

Is there any better front controller support provided by Stripes, or is it a completely different design than Spring MVC? (i.e., I have to call methods from the view using EL to retrieve the data, as some of the examples do)

Thanks!

+6
java stripes
source share
3 answers

A typical Stripes MVC design would look something like the code below.

The JPA object is automatically loaded by the Stripes interceptor provided by the Stripersist (but this can also be easily implemented as you wish , if you like). Thus, in this example, the request http://your.app/show-order-12.html will load the order with identifier 12 from the database and display it on the page.

Controller (OrderAction.java):

@UrlBinding("/show-order-{order=}.html") public class OrderAction implements ActionBean { private ActionBeanContext context; private Order order; public ActionBeanContext getContext() { return context; } public void setContext(ActionBeanContext context) { this.context = context; } public void setOrder(Order order) { this.order = order; } public String getOrder() { return order; } @DefaultHandler public Resolution view() { return new ForwardResolution("/WEB-INF/jsp/order.jsp"); } } 

View (order.jsp):

 <html><body> Order id: ${actionBean.order.id}<br/> Order name: ${actionBean.order.name)<br/> Order total: ${actionBean.order.total)<br/> </body></html> 

Model (Order.java):

 @Entity public class Order implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; private Integer total; public String getName() { return name; } public Integer getTotal() { return total; } } 

By the way, there is a really great short (!) Book about Stripes that covers all of these things:

Stripes: ... and Java Web Development is fun again!

+5
source share

Ok, I figured it out. Attributes added to the HttpServletRequest (retrieved from the context) are available on the page receiving the ForwardRedirect

IE context.getRequest (). setAttribute ("attr1", "request attribute 1"); return a new ForwardResolution ("/WEB-INF/pages/hello.jsp");

In hello.jsp $ {Attr1} is available ... yay!

+1
source share

There is one nice solution for nopCommerce 3.20 (MVC). This is a paid plugin that supports, authorizes, authorizes / captures, returns and partial refunds. PCI compliance, CC information not available on db http://shop.wama-net.com/en/stripe-payment-plugin-for-nopcommerce

Jacquie

0
source share

All Articles