JSF: ActionListener - set bean properties and open another page


Web tier: servlets, JSP, Web frameworks: JSF: ActionListener - set bean properties and open another page

  1. Hi, I have a simple usecase as follows: 1. Use a dropdown to select a table 2. Display some table data with "detail" button. On clicking the detail button, store the row information and redirect to detail page. 3. Display the data that was stored in step 2. Some more information is as follows My backing bean is also the action listener.. public class Form implements ActionListener It constructs the datatable in java code and uses component binding. Each row has a detail button that is coded as: //Add detail column column = new UIColumn(); UIOutput header = new UIOutput(); header.setValue("Detail"); column.setHeader(header); HtmlCommandButton detailButton = new HtmlCommandButton(); detailButton.addActionListener(this); detailButton.setValue ("Detail"); column.getChildren().add(detailButton); datatable.getChildren().add(column); The processAction(ActionEvent anEvent) sets a String[] and opens the detail page: public void processAction(ActionEvent anEvent) throws AbortProcessingException { UIComponent tmpComponent = anEvent.getComponent (); while (null != tmpComponent && !(tmpComponent instanceof UIData)) { tmpComponent = tmpComponent.getParent(); } if (tmpComponent != null && (tmpComponent instanceof UIData)) { Object tmpRowData = ((UIData) tmpComponent).getRowData(); if (tmpRowData instanceof String[]) { detail = (String[]) tmpRowData; if (detail != null) { try { FacesContext.getCurrentInstance().getExternalContext().redirect("detail.faces"); } catch (IOException ex) { System.err.println("IOException"+ex.getMessage()); System.err.println(ex.getStackTrace()); } } } } } Now when the detail.jsp opens, it gives a null pointer exception because String[] detail is null again. Can anyone help me figure out what is being done wrong here? Please help. Thanks
  2. What is the scope of the detail array?
  3. Session scope..