You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Jack Rudnick <jr...@bea.com> on 2005/07/21 20:19:49 UTC

Passing a form bean to a "popup"

In the latest examples of how to use "popups" with beehive, there is a simple example of how a netui:button can call a nested action, and when this nested action returns it provides the display in a popup widow.
 
Would it be possible to pass a formbean to this nested action with values that are already set?  Here we hope to have a value on the parent form that we can pass to the nested action, then the nested action can use this to do whatever it needs with this value.  In other words, we may have a String value on the parent form called Xyz.  If we wish to pass this to the form for the popup, so that we can display it or use it, what is the provided method?
 
Does this sound clear?  Any ideas?

Re: Passing a form bean to a "popup"

Posted by Rich Feit <ri...@gmail.com>.
Hi Jack,

I do this a lot -- usually I just use the same form bean as input and 
output for the nested page flow:

    @Jpf.Controller(
        nested=true,
        simpleActions={
            @Jpf.SimpleAction(name="done", returnAction="nestedDone", 
outputFormBean="_form")
        }
    )
    public class NestedFlow extends PageFlowController
    {
        private MyForm _form;

        @Jpf.Action(
            useFormBean="_form",
            forwards={
                @Jpf.Forward(name="index", path="index.jsp")
            }
        )
        public Forward begin(MyForm form)
        {
            return new Forward("index");
        }

        public static class MyForm implements java.io.Serializable
        {
            private String _foo;

            public String getFoo()
            {
                return _foo;
            }

            public void setFoo(String foo)
            {
                _foo = foo;
            }
        }
    }

Then, I do something like this from another page flow to handle the call 
and return of NestedFlow.jpf:

    @Jpf.Action(
        forwards={
            @Jpf.Forward(name="nestedFlow", 
path="nested/NestedFlow.jpf", outputFormBeanType=NestedFlow.MyForm.class)
        }
    )
    public Forward goNested()
    {
        NestedFlow.MyForm initBean = new NestedFlow.MyForm();
        initBean.setFoo("got it");
        return new Forward("nestedFlow", initBean);
    }

    @Jpf.Action(
        forwards={
            @Jpf.Forward(name="index", path="index.jsp")
        }
    )
    public Forward nestedDone(NestedFlow.MyForm returnFormBean)
    {
        System.err.println("foo: " + returnFormBean.getFoo());
        return new Forward("index");
    }

In this case I use the 'useFormBean' attribute as a convenience to make 
the nested page flow store the initialization bean automatically, but 
you could hang onto it manually as well.

Is that what you're looking for?

Rich

Jack Rudnick wrote:

>In the latest examples of how to use "popups" with beehive, there is a simple example of how a netui:button can call a nested action, and when this nested action returns it provides the display in a popup widow.
> 
>Would it be possible to pass a formbean to this nested action with values that are already set?  Here we hope to have a value on the parent form that we can pass to the nested action, then the nested action can use this to do whatever it needs with this value.  In other words, we may have a String value on the parent form called Xyz.  If we wish to pass this to the form for the popup, so that we can display it or use it, what is the provided method?
> 
>Does this sound clear?  Any ideas?
>  
>