ok i am writing this mail to ask you all about a design question, this is my problem:
i have a productsList.jsp page with a list of Products displayed in a dataTable and each row has a commandButton with label "DETAILS", i want that once pressed a new page productDetails.jsp is displayed with the details of the selected Product, now i have readed many example but each one use a diferent strategy and i am searching to know wich is the best one; the productsList.jsp page use the ProductsListBean.productsList() method to get the list, instead the productDetails.jsp page use the ProductBean managed bean to display the data. these are the strategies i found
 
1) using a UIData binded to the dataTable you can use a commandButton with action="" and in the action method you can get the selected Product using getRowData() method, after getting the selected Project you can store it in session or request so the productDetails.jsp can display the data
 
2) using a comandLink instead of a commandButton and using an actionListener="#{ProductBean.initAction} and a param like <f:param id="hId" name="id" value="#{product.id}" /> so that in the initAction method the bean is filled using the hId param
 
public void initAction(ActionEvent event) {
  UIParameter parameter = (UIParameter) event.getComponent().findComponent("hId");
  setId(Integer.parseInt(parameter.getValue().toString()));
  if(getId() != 0) {
   printLogger.println("populating ProductBean with id " + getId());
   Product realProduct  = LookupManager.getProduct Manager().getProductByPk(this.getId());
   try {
    BeanUtils.copyProperties(this,realProduct );
   } catch (IllegalAccessException e) {
   } catch (InvocationTargetException e) {
   }
  }
 }
 
there is not immediate="true" so the method is called after the bean costructor
 
now wich strategy is better? do you know other strategies?
 
tnx



----
Email.it, the professional e-mail, gratis per te:clicca qui

Sponsor:
Per il tuo progetto da realizzare, Findomestic ti offre finanziamenti chiari e semplici senza anticipi, clicca e scopri come!
Clicca qui


Reply via email to