struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorge Sousa <jorge.so...@wit-software.com>
Subject REST Plugin
Date Wed, 03 Mar 2010 15:00:41 GMT
Hi,

I'm facing some problems using this plugin, i want to handle multiple 
parameters,something like the example:
http://localhost:6970/transferCredit?fromMSISDN=123456789&fromMSISDNType=coiso&toMSISDN=123456789&EuroCentsAmount=10

I checked the available examples ( available in 
org.apache.struts2.rest.example) and all of them only owns a id that 
fetches the parameter.

Below are the code of the example that i mencioned.

Any of you faced the same problem?
*
One more question:*

I used the name OrdersController in the class that implements my methods 
and everything works fine, why did this stoped working when  i changed 
the name to OrdersHandlingController? I keeped the Controller at the 
end, i think this should have worked.

Thanks in advance,

Jorge Sousa from Portugal

//======================================================================
Code Example:

public class OrdersController extends BaseAction implements 
ModelDriven<Object>, Validateable{

     private Order model = new Order();
     private String id;
     private Collection<Order> list;
     private OrdersService ordersService = new OrdersService();

     // GET /orders/1
     public HttpHeaders show() {
         return new DefaultHttpHeaders("show");
     }

     // GET /orders
     public HttpHeaders index() {
         list = ordersService.getAll();
         return new DefaultHttpHeaders("index")
             .disableCaching();
     }

     // GET /orders/1/edit
     public String edit() {
         return "edit";
     }

     // GET /orders/new
     public String editNew() {
         model = new Order();
         return "editNew";
     }

     // GET /orders/1/deleteConfirm
     public String deleteConfirm() {
         return "deleteConfirm";
     }

     // DELETE /orders/1
     public String destroy() {
         ordersService.remove(id);
         addActionMessage("Order removed successfully");
         return "success";
     }

     // POST /orders
     public HttpHeaders create() {
         ordersService.save(model);
         addActionMessage("New order created successfully");
         return new DefaultHttpHeaders("success")
             .setLocationId(model.getId());
     }

     // PUT /orders/1
     public String update() {
         ordersService.save(model);
         addActionMessage("Order updated successfully");
         return "success";
     }

     public void validate() {
         if (model.getClientName() == null || 
model.getClientName().length() ==0) {
             addFieldError("clientName", "The client name is empty");
         }
     }

     public void setId(String id) {
         if (id != null) {
             this.model = ordersService.get(id);
         }
         this.id = id;
     }

     public Object getModel() {
         return (list != null ? list : model);
     }

}


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message