You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aneesha Govil <po...@gmail.com> on 2006/09/27 14:16:35 UTC

Some bean properties lose values on redirect

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

Re: Some bean properties lose values on redirect

Posted by Aneesha Govil <po...@gmail.com>.
I store the value here in the bean property in the processAction method
>detail = (String[]) tmpRowData;

detail is a property of the managed bean I am calling redirect from. UIData
is what I use to get the value from. It's like getting the row information
whose detail is to be displayed on the next page.

Thanks so much for reading.
Aneesha

On 9/30/06, Andrew Robinson <an...@gmail.com> wrote:
>
> Did you persist the properties in the bean or in a bound component. I
> thought from your example you have the properties persisted in the
> UIData object.
>
> On 9/29/06, Aneesha Govil <po...@gmail.com> wrote:
> > It is in a bean with session scope. The values that I am not using were
> > persisted and the ones that I needed were reinitialized. Weird problem.
> >
> > Thanks for trying to help
> > Aneesha
> >
> >
> >  On 9/29/06, Andrew Robinson <an...@gmail.com> wrote:
> > > Store the values in a non-request backing bean (session, conversation,
> > etc)
> > >
> > > On 9/28/06, Aneesha Govil <po...@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 <po...@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
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Some bean properties lose values on redirect

Posted by Andrew Robinson <an...@gmail.com>.
Did you persist the properties in the bean or in a bound component. I
thought from your example you have the properties persisted in the
UIData object.

On 9/29/06, Aneesha Govil <po...@gmail.com> wrote:
> It is in a bean with session scope. The values that I am not using were
> persisted and the ones that I needed were reinitialized. Weird problem.
>
> Thanks for trying to help
> Aneesha
>
>
>  On 9/29/06, Andrew Robinson <an...@gmail.com> wrote:
> > Store the values in a non-request backing bean (session, conversation,
> etc)
> >
> > On 9/28/06, Aneesha Govil <po...@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 <po...@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
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
>
>

Re: Some bean properties lose values on redirect

Posted by Aneesha Govil <po...@gmail.com>.
It is in a bean with session scope. The values that I am not using were
persisted and the ones that I needed were reinitialized. Weird problem.

Thanks for trying to help
Aneesha

On 9/29/06, Andrew Robinson <an...@gmail.com> wrote:
>
> Store the values in a non-request backing bean (session, conversation,
> etc)
>
> On 9/28/06, Aneesha Govil <po...@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 <an...@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 <po...@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
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Some bean properties lose values on redirect

Posted by Andrew Robinson <an...@gmail.com>.
Store the values in a non-request backing bean (session, conversation, etc)

On 9/28/06, Aneesha Govil <po...@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 <an...@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 <po...@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
> > > >
> > >
> > >
> >
>
>

Possibility to log all requests _detailled_?

Posted by Stefan Schütz <sc...@arcor.de>.
Hi folks,

i'm sitting here over my application which is built with
MyFaces, Spring and Hibernate and searching for a way
to log all requests (GETs _and_ POSTs).
Not that problem so far. But i like to know some things exactly:

=> which Action is invoked and which params are submitted.


I've tried to get this data inside a filter (via HttpServletRequest),
but no luck.

I think, i have to implement a "Faces-dependent" solution e.g. extend  
the FacesController.
But how? Is there anybody who can help me?

Thanks so far,
Stefan

Re: Some bean properties lose values on redirect

Posted by Aneesha Govil <po...@gmail.com>.
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 <an...@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 <po...@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
> > >
> >
> >
>

Re: Some bean properties lose values on redirect

Posted by Andrew Robinson <an...@gmail.com>.
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 <po...@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
> >
>
>

Re: Some bean properties lose values on redirect

Posted by Aneesha Govil <po...@gmail.com>.
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 <po...@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
>