Advertisement
Guest User

Untitled

a guest
May 6th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public class ProductDetails extends Panel {
  2.  
  3. @EJB
  4. private ProductServicesLocal productServices;
  5. private Product product;
  6.  
  7.  
  8. public ProductDetails(String id, Product product) {
  9. super(id);
  10. setOutputMarkupId(true);
  11. this.theModel = new CompoundPropertyModel(product);
  12. add(new Label("id"));
  13.  
  14. Form<Product> form = new Form<Product>("form", this.theModel);
  15. form.add(new AjaxEditableLabel<String>("codProduct"));
  16. add(new AjaxLink<String>("save") {
  17. @Override
  18. public void onClick(AjaxRequestTarget target) {
  19. System.out.println("saving product .... ");
  20. }
  21. });
  22. add(form);
  23. }
  24.  
  25. public void setCurrentProduct(Product product) {
  26. this.theModel.setObject(product);
  27. }
  28.  
  29. }
  30.  
  31.  
  32. This is from another component to update the panel:
  33. @Override
  34. public void onClick(AjaxRequestTarget target) {
  35. Product product = item.getModelObject();
  36. productDetails.setCurrentProduct(product);
  37. target.addComponent(productDetails);
  38. System.out.println(product.getId());
  39. }
  40. };
  41. item.add(link);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement