myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: Some bean properties lose values on redirect
Date Fri, 29 Sep 2006 15:45:36 GMT
Store the values in a non-request backing bean (session, conversation, etc)

On 9/28/06, Aneesha Govil <popcorn09@gmail.com> wrote:
> I need to store some values on an action and open a new page displaying
> something in accordance with the values saved. Is there any workaround to
> accomplish this?
>
> Thanks for replying.
> Aneesha
>
>
>  On 9/28/06, Andrew Robinson <andrew.rw.robinson@gmail.com> wrote:
> > When you redirect to a new page, the bound component should not travel
> > to the new view with you, so it should make sense that the component
> > binding is now null and if you tried to access it, it would be
> > created. I am not 100% sure of what is going on, but that is my best
> > guess.
> >
> > On 9/27/06, Aneesha Govil <popcorn09@gmail.com> wrote:
> > > Hi,
> > >
> > > Here is some more information:
> > >
> > > 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
> > >
> > >
> > > On 9/27/06, Aneesha Govil < popcorn09@gmail.com> wrote:
> > > > 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.
> > > >
> > > > I am using an ActionListener for the detail button that stores the row
> > > data. I have debugged this, it gets stored. However, after redirect the
> data
> > > is wiped out, the property is null again. I am using another propery to
> > > create HtmlPanelGroup in java code. This also gets reinitialized.
> Strangely,
> > > all other properties of the bean remain intact.
> > > >
> > > > Can anyone help with this?
> > > > I can provide the source code and whatever information is required.
> This
> > > seems like a really weird problem. Why aren't other values wiped out?
> > > >
> > > > Please help!
> > > >
> > > > Thanks,
> > > > Aneesha
> > > >
> > >
> > >
> >
>
>

Mime
View raw message