Simple get/set DisplayFieldValue

I'm having a problem setting a Jato HiddenField. I have a combobox on

page 1 of my app. In my request handler for page 1 I retrieve the

value selected from the combobox and I try to set a HiddenField object

(that resides on page 2 of my app) with the value from the combobox.

Here's my code in my page 1 request handler...

ViewBean targetView =

getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

System.out.println("***********************"+

getDisplayFieldValue(CHILD_MENU_DOC_TYPE) +"********************");

targetView.setDisplayFieldValue(VoyagerCreateChoic

eViewBean.CHILD_HIDDEN_DOCTYPE,

getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

targetView.forwardTo(getRequestContext());

In the System.out.println() statement, I'm getting the correct value

from the combobox (CHILD_MENU_DOC_TYPE). But for some reason the

targetView.setDisplayFieldValue(VoyagerCreateChoic

eViewBean.CHILD_HIDDEN_DOCTYPE,

getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

HiddenField object for the following page

(VoyagerCreateChoiceViewBean).

Any idea as to what I'm doing wrong?

I've put a print statement before and after the registerChildren()

method that resides in my page 2 ViewBean

(VoyagerCreateChoiceViewBean) and I get a *null* value when I try and

getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the HiddenFiled

object that resides on page 2 of my app.

- Billy -

[1572 byte] By [Guest] at [2007-11-25 9:26:49]
# 1

Can we see the JSP and the ViewBean class (the register and create child

parts at least).

One observation:

When you do getViewBean(...), you don't have to do Class.forName(...),

you can simply do this:

getViewBean(FooViewBean.class)

Don't know if there is any real performance difference (Todd, Mike,

Matt... comments?)

But just seems simpler and no need for literals (the viewbean constant).

craig

chubbykidd wrote:

>I'm having a problem setting a Jato HiddenField. I have a combobox on

>page 1 of my app. In my request handler for page 1 I retrieve the

>value selected from the combobox and I try to set a HiddenField object

>(that resides on page 2 of my app) with the value from the combobox.

>Here's my code in my page 1 request handler...

>

>ViewBean targetView =

>getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

>System.out.println("***********************"+

>getDisplayFieldValue(CHILD_MENU_DOC_TYPE) +"********************");

>

>targetView.setDisplayFieldValue(VoyagerCreateChoic

>eViewBean.CHILD_HIDDEN_DOCTYPE,

>getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

>targetView.forwardTo(getRequestContext());

>

>In the System.out.println() statement, I'm getting the correct value

>from the combobox (CHILD_MENU_DOC_TYPE). But for some reason the

>targetView.setDisplayFieldValue(VoyagerCreateChoic

>eViewBean.CHILD_HIDDEN_DOCTYPE,

>getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

>HiddenField object for the following page

>(VoyagerCreateChoiceViewBean).

>

>Any idea as to what I'm doing wrong?

>

>I've put a print statement before and after the registerChildren()

>method that resides in my page 2 ViewBean

>(VoyagerCreateChoiceViewBean) and I get a *null* value when I try and

>getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the HiddenFiled

>object that resides on page 2 of my app.

>

>- Billy -

>

>

>

>

>To download the latest version of JATO, please visit:

><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

>

>For more information about JATO, please visit:

><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

>

>

>

>

>

>

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 2

Hi Chubby

Try the following:

((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

.setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

Hope this works,

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> I've embedded the jsp and ViewBean in this e-mail. If it's difficult

> to read, let me know if I can e-mail the two files to you....

>

>

> Here is my jsp page that has the HiddenField within the form.....

>

>

> <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> <jato:useViewBean

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

an">

> <%--

> NOTE: The following declaration is only necessary if you are using

the

> TEI taglib workaround

> (which is enabled by default). See the JATO Tag Library

> documentation for complete

> information.

> --%>

> <jsp:useBean id="viewBean"

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> <!-- Define the resource bundle, html, head, meta, stylesheet and

body

> tags -->

> <cc:header pageTitle="Voyager Create Document Complexity"

> copyrightYear="2002"

> baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> bundleID="myBundle">

> <script src="/voyager/js/voyager.js"></script>

> <%-- Include Masthead With Tabs --%>

> <jsp:include page="VoyagerHeader.jsp" flush="true" />

> <jato:form name="VoyagerCreateChoice" method="post">

> <jato:hidden name="doctype" />

> <table align="left" cellpadding="3" cellspacing="3" border="0"

> width="600">

> <tr>

> <td width="125"> </td>

> <td width="*" align="left" class="plaintxt"><jato:text

> name="intro_label" /></td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"

class="plaintxt"><jato:radioButtons

> name="complexity" /></td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"> </td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"><cc:button name="create" /></td>

> </tr>

> </table>

> </jato:form>

> </cc:header>

> </jato:useViewBean>

>

> --

--

>

> Here is my ViewBean associated to the jsp page above...

>

> package com.sun.cms.voyager.voyagermodule;

>

> import java.io.*;

> import java.lang.reflect.*;

> import java.sql.*;

> import java.util.*;

> import javax.servlet.*;

> import javax.servlet.http.*;

>

> import com.sun.cms.fw.*;

> import com.sun.cms.voyager.voyagermodule.*;

>

> import com.iplanet.jato.*;

> import com.iplanet.jato.model.*;

> import com.iplanet.jato.model.sql.*;

> import com.iplanet.jato.util.*;

> import com.iplanet.jato.view.*;

> import com.iplanet.jato.view.event.*;

> import com.iplanet.jato.view.html.*;

>

> import com.sun.web.ui.view.html.*;

>

> /**

> * This class represents the Create Choice screen that

> * follows when a user chooses to create a document

> *

> * @author Billy Bacon

> */

> public class VoyagerCreateChoiceViewBean extends VoyagerViewBeanBase

> implements IVoyagerConstants {

>

> // Mandatory members

> // The "logical" name for this page.

> public static final String PAGE_NAME =

VOYAGER_CREATE_CHOICE_PAGE;

>

> // The URL that points to the JSP which uses this ViewBean

> public static final String DEFAULT_DISPLAY_URL =

> "/voyager/"+PAGE_NAME+".jsp";

>

> // Recommended members

> // String constants for child field names. This is simply good

> coding practice

> // to minimize use of string literals.

> public static final String CHILD_LABEL_INTRO

= "intro_label";

> public static final String CHILD_LABEL_SIMPLE

= "simple_label";

> public static final String CHILD_LABEL_COMPLEX

= "complex_label";

> public static final String CHILD_RADIO_COMPLEXITY

= "complexity";

> public static final String CHILD_HIDDEN_DOCTYPE

= "doctype";

> public static final String CHILD_BUTTON_CREATE = "create";

>

>

> ////////////////////////////////////////////////////////////////////

////////

> // Instance variables

>

> ////////////////////////////////////////////////////////////////////

////////

>

> // Model instance references - optional, recommended

> // (See Model accessors & mutators above)

> // NOTE: Do NOT create instance variables that refer to child

> views (i.e. display fields)

> // Instead create accessors according to the examples above

>

> //private VoyagerHomeSummaryModel homeSummaryModel = null;

> //private VoyagerToDoModel toDoModel

= null;

> //private VoyagerDraftModel draftModel = null;

> //private VoyagerMyDocsModelmyDocsModel = null;

>

> // The first string array are the labels, the second string

array

> are the values.

> // This list populates the RadioButtonGroup for document type

> complexity.

> private static OptionList options = new OptionList(new String[]

> {"Simple Document", "Complex Document"}, new String[]{"simple",

> "complex"});

>

> /**

> * Default constructor

> *

> */

> public VoyagerCreateChoiceViewBean() {

> super(PAGE_NAME);

> setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> registerChildren();

> }

>

>

>

>

> ////////////////////////////////////////////////////////////////////

////////////

> // Child methods - mandatory

>

> ////////////////////////////////////////////////////////////////////

////////////

>

> /**

> *

> *

> */

> protected void registerChildren() {

> // Add an entry for each child. Note, the children

are not instantiated

> // at this time. Instead, child instantiation is

handled in a lazy

> fashion.

> registerChild(CHILD_LABEL_INTRO,

StaticTextField.class);

> registerChild(CHILD_LABEL_SIMPLE,

StaticTextField.class);

> registerChild(CHILD_LABEL_COMPLEX,

StaticTextField.class);

> registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> registerChild(CHILD_RADIO_COMPLEXITY,

RadioButtonGroup.class);

> registerChild(CHILD_HIDDEN_DOCTYPE,

HiddenField.class);

> }

>

>

> /**

> * Create the child objects for the related jsp page. You must

> register/create

> * an object for every form element or any element that you'd

like to

> support

> * localization for

> *

> * @return a View that represents the element on the jsp page.

> * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> */

> protected View createChild(String name) {

> if(name.equals(CHILD_LABEL_INTRO)) {

> StaticTextField child = new StaticTextField(this,

> getResourceBundleModel(Locale.ENGLISH), name, "createchoice.intro",

> "?", null);

> return child;

> } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> RadioButtonGroup child = new RadioButtonGroup(this,

name,

> "0");

> child.setOptions(options);

> return child;

> } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> HiddenField child = new HiddenField(this,

name, "");

> return child;

> } else if(name.equals(CHILD_BUTTON_CREATE)) {

> CCButton child = new CCButton(this,

> getResourceBundleModel(Locale.ENGLISH), name, "createchoice.create",

> "?", null);

> return child;

> } else {

> throw new IllegalArgumentException("Invalid child name

> \""+name+"\"");

> }

> }

>

>

>

>

> ////////////////////////////////////////////////////////////////////

////////////

> // Request event handler methods - mandatory for button and HREF

> fields

>

> ////////////////////////////////////////////////////////////////////

////////////

>

> public void handleCreateRequest(RequestInvocationEvent event)

> throws ServletException, IOException, ClassNotFoundException,

Exception {

> try {

> ViewBean targetView =

> getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> targetView.setDisplayFieldValue

(CHILD_HIDDEN_DOCTYPE,

> getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

>

> targetView.setDisplayFieldValue

(VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> targetView.forwardTo(getRequestContext());

> } catch(ClassNotFoundException cnfe) {

> // Will change this when development is

finished....

> throw new ClassNotFoundException

("VoyagerCreateChoiceViewBean class

> was not found");

> } catch(Exception e) {

> e.printStackTrace();

> }

> }

> }

>

>

>

>

>

>

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

wrote:

> > Can we see the JSP and the ViewBean class (the register and create

> child

> > parts at least).

> >

> > One observation:

> > When you do getViewBean(...), you don't have to do Class.forName

(...),

> > you can simply do this:

> > getViewBean(FooViewBean.class)

> >

> > Don't know if there is any real performance difference (Todd,

Mike,

> > Matt... comments?)

> > But just seems simpler and no need for literals (the viewbean

constant).

> >

> > craig

> >

> >

> > chubbykidd wrote:

> >

> > >I'm having a problem setting a Jato HiddenField. I have a

combobox on

> > >page 1 of my app. In my request handler for page 1 I retrieve the

> > >value selected from the combobox and I try to set a HiddenField

object

> > >(that resides on page 2 of my app) with the value from the

combobox.

> > >Here's my code in my page 1 request handler...

> > >

> > >ViewBean targetView =

> > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > >System.out.println("***********************"+

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

+"********************");

> > >

> > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > >targetView.forwardTo(getRequestContext());

> > >

> > >In the System.out.println() statement, I'm getting the correct

value

> > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason the

> > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > >HiddenField object for the following page

> > >(VoyagerCreateChoiceViewBean).

> > >

> > >Any idea as to what I'm doing wrong?

> > >

> > >I've put a print statement before and after the registerChildren

()

> > >method that resides in my page 2 ViewBean

> > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

try and

> > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

HiddenFiled

> > >object that resides on page 2 of my app.

> > >

> > >- Billy -

> > >

> > >

> > >

> > >

> > >To download the latest version of JATO, please visit:

> > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > >

> > >For more information about JATO, please visit:

> > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > >

> > >

> > >

> > >

> > >

> > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 3

Hi Chubby

Try the following:

((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

.setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

Hope this works,

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> I've embedded the jsp and ViewBean in this e-mail. If it's difficult

> to read, let me know if I can e-mail the two files to you....

>

>

> Here is my jsp page that has the HiddenField within the form.....

>

>

> <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> <jato:useViewBean

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

an">

> <%--

> NOTE: The following declaration is only necessary if you are using

the

> TEI taglib workaround

> (which is enabled by default). See the JATO Tag Library

> documentation for complete

> information.

> --%>

> <jsp:useBean id="viewBean"

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> <!-- Define the resource bundle, html, head, meta, stylesheet and

body

> tags -->

> <cc:header pageTitle="Voyager Create Document Complexity"

> copyrightYear="2002"

> baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> bundleID="myBundle">

> <script src="/voyager/js/voyager.js"></script>

> <%-- Include Masthead With Tabs --%>

> <jsp:include page="VoyagerHeader.jsp" flush="true" />

> <jato:form name="VoyagerCreateChoice" method="post">

> <jato:hidden name="doctype" />

> <table align="left" cellpadding="3" cellspacing="3" border="0"

> width="600">

> <tr>

> <td width="125"> </td>

> <td width="*" align="left" class="plaintxt"><jato:text

> name="intro_label" /></td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"

class="plaintxt"><jato:radioButtons

> name="complexity" /></td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"> </td>

> </tr>

> <tr>

> <td width="125"> </td>

> <td width="*" align="left"><cc:button name="create" /></td>

> </tr>

> </table>

> </jato:form>

> </cc:header>

> </jato:useViewBean>

>

> --

--

>

> Here is my ViewBean associated to the jsp page above...

>

> package com.sun.cms.voyager.voyagermodule;

>

> import java.io.*;

> import java.lang.reflect.*;

> import java.sql.*;

> import java.util.*;

> import javax.servlet.*;

> import javax.servlet.http.*;

>

> import com.sun.cms.fw.*;

> import com.sun.cms.voyager.voyagermodule.*;

>

> import com.iplanet.jato.*;

> import com.iplanet.jato.model.*;

> import com.iplanet.jato.model.sql.*;

> import com.iplanet.jato.util.*;

> import com.iplanet.jato.view.*;

> import com.iplanet.jato.view.event.*;

> import com.iplanet.jato.view.html.*;

>

> import com.sun.web.ui.view.html.*;

>

> /**

> * This class represents the Create Choice screen that

> * follows when a user chooses to create a document

> *

> * @author Billy Bacon

> */

> public class VoyagerCreateChoiceViewBean extends VoyagerViewBeanBase

> implements IVoyagerConstants {

>

> // Mandatory members

> // The "logical" name for this page.

> public static final String PAGE_NAME =

VOYAGER_CREATE_CHOICE_PAGE;

>

> // The URL that points to the JSP which uses this ViewBean

> public static final String DEFAULT_DISPLAY_URL =

> "/voyager/"+PAGE_NAME+".jsp";

>

> // Recommended members

> // String constants for child field names. This is simply good

> coding practice

> // to minimize use of string literals.

> public static final String CHILD_LABEL_INTRO

= "intro_label";

> public static final String CHILD_LABEL_SIMPLE

= "simple_label";

> public static final String CHILD_LABEL_COMPLEX

= "complex_label";

> public static final String CHILD_RADIO_COMPLEXITY

= "complexity";

> public static final String CHILD_HIDDEN_DOCTYPE

= "doctype";

> public static final String CHILD_BUTTON_CREATE = "create";

>

>

> ////////////////////////////////////////////////////////////////////

////////

> // Instance variables

>

> ////////////////////////////////////////////////////////////////////

////////

>

> // Model instance references - optional, recommended

> // (See Model accessors & mutators above)

> // NOTE: Do NOT create instance variables that refer to child

> views (i.e. display fields)

> // Instead create accessors according to the examples above

>

> //private VoyagerHomeSummaryModel homeSummaryModel = null;

> //private VoyagerToDoModel toDoModel

= null;

> //private VoyagerDraftModel draftModel = null;

> //private VoyagerMyDocsModelmyDocsModel = null;

>

> // The first string array are the labels, the second string

array

> are the values.

> // This list populates the RadioButtonGroup for document type

> complexity.

> private static OptionList options = new OptionList(new String[]

> {"Simple Document", "Complex Document"}, new String[]{"simple",

> "complex"});

>

> /**

> * Default constructor

> *

> */

> public VoyagerCreateChoiceViewBean() {

> super(PAGE_NAME);

> setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> registerChildren();

> }

>

>

>

>

> ////////////////////////////////////////////////////////////////////

////////////

> // Child methods - mandatory

>

> ////////////////////////////////////////////////////////////////////

////////////

>

> /**

> *

> *

> */

> protected void registerChildren() {

> // Add an entry for each child. Note, the children

are not instantiated

> // at this time. Instead, child instantiation is

handled in a lazy

> fashion.

> registerChild(CHILD_LABEL_INTRO,

StaticTextField.class);

> registerChild(CHILD_LABEL_SIMPLE,

StaticTextField.class);

> registerChild(CHILD_LABEL_COMPLEX,

StaticTextField.class);

> registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> registerChild(CHILD_RADIO_COMPLEXITY,

RadioButtonGroup.class);

> registerChild(CHILD_HIDDEN_DOCTYPE,

HiddenField.class);

> }

>

>

> /**

> * Create the child objects for the related jsp page. You must

> register/create

> * an object for every form element or any element that you'd

like to

> support

> * localization for

> *

> * @return a View that represents the element on the jsp page.

> * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> */

> protected View createChild(String name) {

> if(name.equals(CHILD_LABEL_INTRO)) {

> StaticTextField child = new StaticTextField(this,

> getResourceBundleModel(Locale.ENGLISH), name, "createchoice.intro",

> "?", null);

> return child;

> } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> RadioButtonGroup child = new RadioButtonGroup(this,

name,

> "0");

> child.setOptions(options);

> return child;

> } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> HiddenField child = new HiddenField(this,

name, "");

> return child;

> } else if(name.equals(CHILD_BUTTON_CREATE)) {

> CCButton child = new CCButton(this,

> getResourceBundleModel(Locale.ENGLISH), name, "createchoice.create",

> "?", null);

> return child;

> } else {

> throw new IllegalArgumentException("Invalid child name

> \""+name+"\"");

> }

> }

>

>

>

>

> ////////////////////////////////////////////////////////////////////

////////////

> // Request event handler methods - mandatory for button and HREF

> fields

>

> ////////////////////////////////////////////////////////////////////

////////////

>

> public void handleCreateRequest(RequestInvocationEvent event)

> throws ServletException, IOException, ClassNotFoundException,

Exception {

> try {

> ViewBean targetView =

> getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> targetView.setDisplayFieldValue

(CHILD_HIDDEN_DOCTYPE,

> getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

>

> targetView.setDisplayFieldValue

(VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> targetView.forwardTo(getRequestContext());

> } catch(ClassNotFoundException cnfe) {

> // Will change this when development is

finished....

> throw new ClassNotFoundException

("VoyagerCreateChoiceViewBean class

> was not found");

> } catch(Exception e) {

> e.printStackTrace();

> }

> }

> }

>

>

>

>

>

>

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

wrote:

> > Can we see the JSP and the ViewBean class (the register and create

> child

> > parts at least).

> >

> > One observation:

> > When you do getViewBean(...), you don't have to do Class.forName

(...),

> > you can simply do this:

> > getViewBean(FooViewBean.class)

> >

> > Don't know if there is any real performance difference (Todd,

Mike,

> > Matt... comments?)

> > But just seems simpler and no need for literals (the viewbean

constant).

> >

> > craig

> >

> >

> > chubbykidd wrote:

> >

> > >I'm having a problem setting a Jato HiddenField. I have a

combobox on

> > >page 1 of my app. In my request handler for page 1 I retrieve the

> > >value selected from the combobox and I try to set a HiddenField

object

> > >(that resides on page 2 of my app) with the value from the

combobox.

> > >Here's my code in my page 1 request handler...

> > >

> > >ViewBean targetView =

> > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > >System.out.println("***********************"+

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

+"********************");

> > >

> > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > >targetView.forwardTo(getRequestContext());

> > >

> > >In the System.out.println() statement, I'm getting the correct

value

> > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason the

> > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > >HiddenField object for the following page

> > >(VoyagerCreateChoiceViewBean).

> > >

> > >Any idea as to what I'm doing wrong?

> > >

> > >I've put a print statement before and after the registerChildren

()

> > >method that resides in my page 2 ViewBean

> > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

try and

> > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

HiddenFiled

> > >object that resides on page 2 of my app.

> > >

> > >- Billy -

> > >

> > >

> > >

> > >

> > >To download the latest version of JATO, please visit:

> > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > >

> > >For more information about JATO, please visit:

> > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > >

> > >

> > >

> > >

> > >

> > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 4

Hi Chubby

I tried the same scenario again on my machine and it works fine.

I am setting the values while I am on one page and then forward to

the other viewbean which contains the child elements for which I have

set the values.

I can send you my samples if it helps..

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "pavan vangara" <<a href="/group/SunONE-JATO/post?protectID=081166234108158209169212055140064253000 032044067209130152">vangara_pavank@y...</a>> wrote:

> Hi Chubby

> Try the following:

>

> ((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

> .setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

>

> Hope this works,

>

> Pavan

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> > I've embedded the jsp and ViewBean in this e-mail. If it's

difficult

> > to read, let me know if I can e-mail the two files to you....

> >

> >

> > Here is my jsp page that has the HiddenField within the form.....

> >

> >

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> > <jato:useViewBean

> >

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

> an">

> > <%--

> > NOTE: The following declaration is only necessary if you are

using

> the

> > TEI taglib workaround

> > (which is enabled by default). See the JATO Tag Library

> > documentation for complete

> > information.

> > --%>

> > <jsp:useBean id="viewBean"

> >

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> > <!-- Define the resource bundle, html, head, meta, stylesheet and

> body

> > tags -->

> > <cc:header pageTitle="Voyager Create Document Complexity"

> > copyrightYear="2002"

> > baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> > bundleID="myBundle">

> > <script src="/voyager/js/voyager.js"></script>

> > <%-- Include Masthead With Tabs --%>

> > <jsp:include page="VoyagerHeader.jsp" flush="true" />

> > <jato:form name="VoyagerCreateChoice" method="post">

> > <jato:hidden name="doctype" />

> > <table align="left" cellpadding="3" cellspacing="3" border="0"

> > width="600">

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left" class="plaintxt"><jato:text

> > name="intro_label" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"

> class="plaintxt"><jato:radioButtons

> > name="complexity" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"> </td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"><cc:button

name="create" /></td>

> > </tr>

> > </table>

> > </jato:form>

> > </cc:header>

> > </jato:useViewBean>

> >

> >

--

> --

> >

> > Here is my ViewBean associated to the jsp page above...

> >

> > package com.sun.cms.voyager.voyagermodule;

> >

> > import java.io.*;

> > import java.lang.reflect.*;

> > import java.sql.*;

> > import java.util.*;

> > import javax.servlet.*;

> > import javax.servlet.http.*;

> >

> > import com.sun.cms.fw.*;

> > import com.sun.cms.voyager.voyagermodule.*;

> >

> > import com.iplanet.jato.*;

> > import com.iplanet.jato.model.*;

> > import com.iplanet.jato.model.sql.*;

> > import com.iplanet.jato.util.*;

> > import com.iplanet.jato.view.*;

> > import com.iplanet.jato.view.event.*;

> > import com.iplanet.jato.view.html.*;

> >

> > import com.sun.web.ui.view.html.*;

> >

> > /**

> > * This class represents the Create Choice screen that

> > * follows when a user chooses to create a document

> > *

> > * @author Billy Bacon

> > */

> > public class VoyagerCreateChoiceViewBean extends

VoyagerViewBeanBase

> > implements IVoyagerConstants {

> >

> > // Mandatory members

> > // The "logical" name for this page.

> > public static final String PAGE_NAME =

> VOYAGER_CREATE_CHOICE_PAGE;

> >

> > // The URL that points to the JSP which uses this ViewBean

> > public static final String DEFAULT_DISPLAY_URL =

> > "/voyager/"+PAGE_NAME+".jsp";

> >

> > // Recommended members

> > // String constants for child field names. This is simply

good

> > coding practice

> > // to minimize use of string literals.

> > public static final String CHILD_LABEL_INTRO

> = "intro_label";

> > public static final String CHILD_LABEL_SIMPLE

> = "simple_label";

> > public static final String CHILD_LABEL_COMPLEX

> = "complex_label";

> > public static final String CHILD_RADIO_COMPLEXITY

> = "complexity";

> > public static final String CHILD_HIDDEN_DOCTYPE

> = "doctype";

> > public static final String CHILD_BUTTON_CREATE

= "create";

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> > // Instance variables

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> >

> > // Model instance references - optional, recommended

> > // (See Model accessors & mutators above)

> > // NOTE: Do NOT create instance variables that refer to child

> > views (i.e. display fields)

> > // Instead create accessors according to the examples above

> >

> > //private VoyagerHomeSummaryModel homeSummaryModel = null;

> > //private VoyagerToDoModel toDoModel

> = null;

> > //private VoyagerDraftModel draftModel = null;

> > //private VoyagerMyDocsModelmyDocsModel = null;

> >

> > // The first string array are the labels, the second string

> array

> > are the values.

> > // This list populates the RadioButtonGroup for document type

> > complexity.

> > private static OptionList options = new OptionList(new String

[]

> > {"Simple Document", "Complex Document"}, new String[]{"simple",

> > "complex"});

> >

> > /**

> > * Default constructor

> > *

> > */

> > public VoyagerCreateChoiceViewBean() {

> > super(PAGE_NAME);

> > setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> > registerChildren();

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Child methods - mandatory

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > /**

> > *

> > *

> > */

> > protected void registerChildren() {

> > // Add an entry for each child. Note, the children

> are not instantiated

> > // at this time. Instead, child instantiation is

> handled in a lazy

> > fashion.

> > registerChild(CHILD_LABEL_INTRO,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_SIMPLE,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_COMPLEX,

> StaticTextField.class);

> > registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> > registerChild(CHILD_RADIO_COMPLEXITY,

> RadioButtonGroup.class);

> > registerChild(CHILD_HIDDEN_DOCTYPE,

> HiddenField.class);

> > }

> >

> >

> > /**

> > * Create the child objects for the related jsp page. You must

> > register/create

> > * an object for every form element or any element that you'd

> like to

> > support

> > * localization for

> > *

> > * @return a View that represents the element on the jsp page.

> > * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> > */

> > protected View createChild(String name) {

> > if(name.equals(CHILD_LABEL_INTRO)) {

> > StaticTextField child = new StaticTextField(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.intro",

> > "?", null);

> > return child;

> > } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> > RadioButtonGroup child = new RadioButtonGroup(this,

> name,

> > "0");

> > child.setOptions(options);

> > return child;

> > } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> > HiddenField child = new HiddenField(this,

> name, "");

> > return child;

> > } else if(name.equals(CHILD_BUTTON_CREATE)) {

> > CCButton child = new CCButton(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.create",

> > "?", null);

> > return child;

> > } else {

> > throw new IllegalArgumentException("Invalid child name

> > \""+name+"\"");

> > }

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Request event handler methods - mandatory for button and

HREF

> > fields

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > public void handleCreateRequest(RequestInvocationEvent event)

> > throws ServletException, IOException, ClassNotFoundException,

> Exception {

> > try {

> > ViewBean targetView =

> > getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> > targetView.setDisplayFieldValue

> (CHILD_HIDDEN_DOCTYPE,

> > getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

> >

> > targetView.setDisplayFieldValue

> (VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> > getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> > targetView.forwardTo(getRequestContext());

> > } catch(ClassNotFoundException cnfe) {

> > // Will change this when development is

> finished....

> > throw new ClassNotFoundException

> ("VoyagerCreateChoiceViewBean class

> > was not found");

> > } catch(Exception e) {

> > e.printStackTrace();

> > }

> > }

> > }

> >

> >

> >

> >

> >

> >

> >

> > In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

> wrote:

> > > Can we see the JSP and the ViewBean class (the register and

create

> > child

> > > parts at least).

> > >

> > > One observation:

> > > When you do getViewBean(...), you don't have to do Class.forName

> (...),

> > > you can simply do this:

> > > getViewBean(FooViewBean.class)

> > >

> > > Don't know if there is any real performance difference (Todd,

> Mike,

> > > Matt... comments?)

> > > But just seems simpler and no need for literals (the viewbean

> constant).

> > >

> > > craig

> > >

> > >

> > > chubbykidd wrote:

> > >

> > > >I'm having a problem setting a Jato HiddenField. I have a

> combobox on

> > > >page 1 of my app. In my request handler for page 1 I retrieve

the

> > > >value selected from the combobox and I try to set a

HiddenField

> object

> > > >(that resides on page 2 of my app) with the value from the

> combobox.

> > > >Here's my code in my page 1 request handler...

> > > >

> > > >ViewBean targetView =

> > > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > > >System.out.println("***********************"+

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

> +"********************");

> > > >

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > > >targetView.forwardTo(getRequestContext());

> > > >

> > > >In the System.out.println() statement, I'm getting the correct

> value

> > > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason

the

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > > >HiddenField object for the following page

> > > >(VoyagerCreateChoiceViewBean).

> > > >

> > > >Any idea as to what I'm doing wrong?

> > > >

> > > >I've put a print statement before and after the

registerChildren

> ()

> > > >method that resides in my page 2 ViewBean

> > > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

> try and

> > > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

> HiddenFiled

> > > >object that resides on page 2 of my app.

> > > >

> > > >- Billy -

> > > >

> > > >

> > > >

> > > >

> > > >To download the latest version of JATO, please visit:

> > > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > > >

> > > >For more information about JATO, please visit:

> > > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > > >

> > > >

> > > >

> > > >

> > > >

> > > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 5

Hi Chubby

I tried the same scenario again on my machine and it works fine.

I am setting the values while I am on one page and then forward to

the other viewbean which contains the child elements for which I have

set the values.

I can send you my samples if it helps..

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "pavan vangara" <<a href="/group/SunONE-JATO/post?protectID=081166234108158209169212055140064253000 032044067209130152">vangara_pavank@y...</a>> wrote:

> Hi Chubby

> Try the following:

>

> ((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

> .setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

>

> Hope this works,

>

> Pavan

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> > I've embedded the jsp and ViewBean in this e-mail. If it's

difficult

> > to read, let me know if I can e-mail the two files to you....

> >

> >

> > Here is my jsp page that has the HiddenField within the form.....

> >

> >

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> > <jato:useViewBean

> >

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

> an">

> > <%--

> > NOTE: The following declaration is only necessary if you are

using

> the

> > TEI taglib workaround

> > (which is enabled by default). See the JATO Tag Library

> > documentation for complete

> > information.

> > --%>

> > <jsp:useBean id="viewBean"

> >

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> > <!-- Define the resource bundle, html, head, meta, stylesheet and

> body

> > tags -->

> > <cc:header pageTitle="Voyager Create Document Complexity"

> > copyrightYear="2002"

> > baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> > bundleID="myBundle">

> > <script src="/voyager/js/voyager.js"></script>

> > <%-- Include Masthead With Tabs --%>

> > <jsp:include page="VoyagerHeader.jsp" flush="true" />

> > <jato:form name="VoyagerCreateChoice" method="post">

> > <jato:hidden name="doctype" />

> > <table align="left" cellpadding="3" cellspacing="3" border="0"

> > width="600">

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left" class="plaintxt"><jato:text

> > name="intro_label" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"

> class="plaintxt"><jato:radioButtons

> > name="complexity" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"> </td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"><cc:button

name="create" /></td>

> > </tr>

> > </table>

> > </jato:form>

> > </cc:header>

> > </jato:useViewBean>

> >

> >

--

> --

> >

> > Here is my ViewBean associated to the jsp page above...

> >

> > package com.sun.cms.voyager.voyagermodule;

> >

> > import java.io.*;

> > import java.lang.reflect.*;

> > import java.sql.*;

> > import java.util.*;

> > import javax.servlet.*;

> > import javax.servlet.http.*;

> >

> > import com.sun.cms.fw.*;

> > import com.sun.cms.voyager.voyagermodule.*;

> >

> > import com.iplanet.jato.*;

> > import com.iplanet.jato.model.*;

> > import com.iplanet.jato.model.sql.*;

> > import com.iplanet.jato.util.*;

> > import com.iplanet.jato.view.*;

> > import com.iplanet.jato.view.event.*;

> > import com.iplanet.jato.view.html.*;

> >

> > import com.sun.web.ui.view.html.*;

> >

> > /**

> > * This class represents the Create Choice screen that

> > * follows when a user chooses to create a document

> > *

> > * @author Billy Bacon

> > */

> > public class VoyagerCreateChoiceViewBean extends

VoyagerViewBeanBase

> > implements IVoyagerConstants {

> >

> > // Mandatory members

> > // The "logical" name for this page.

> > public static final String PAGE_NAME =

> VOYAGER_CREATE_CHOICE_PAGE;

> >

> > // The URL that points to the JSP which uses this ViewBean

> > public static final String DEFAULT_DISPLAY_URL =

> > "/voyager/"+PAGE_NAME+".jsp";

> >

> > // Recommended members

> > // String constants for child field names. This is simply

good

> > coding practice

> > // to minimize use of string literals.

> > public static final String CHILD_LABEL_INTRO

> = "intro_label";

> > public static final String CHILD_LABEL_SIMPLE

> = "simple_label";

> > public static final String CHILD_LABEL_COMPLEX

> = "complex_label";

> > public static final String CHILD_RADIO_COMPLEXITY

> = "complexity";

> > public static final String CHILD_HIDDEN_DOCTYPE

> = "doctype";

> > public static final String CHILD_BUTTON_CREATE

= "create";

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> > // Instance variables

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> >

> > // Model instance references - optional, recommended

> > // (See Model accessors & mutators above)

> > // NOTE: Do NOT create instance variables that refer to child

> > views (i.e. display fields)

> > // Instead create accessors according to the examples above

> >

> > //private VoyagerHomeSummaryModel homeSummaryModel = null;

> > //private VoyagerToDoModel toDoModel

> = null;

> > //private VoyagerDraftModel draftModel = null;

> > //private VoyagerMyDocsModelmyDocsModel = null;

> >

> > // The first string array are the labels, the second string

> array

> > are the values.

> > // This list populates the RadioButtonGroup for document type

> > complexity.

> > private static OptionList options = new OptionList(new String

[]

> > {"Simple Document", "Complex Document"}, new String[]{"simple",

> > "complex"});

> >

> > /**

> > * Default constructor

> > *

> > */

> > public VoyagerCreateChoiceViewBean() {

> > super(PAGE_NAME);

> > setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> > registerChildren();

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Child methods - mandatory

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > /**

> > *

> > *

> > */

> > protected void registerChildren() {

> > // Add an entry for each child. Note, the children

> are not instantiated

> > // at this time. Instead, child instantiation is

> handled in a lazy

> > fashion.

> > registerChild(CHILD_LABEL_INTRO,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_SIMPLE,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_COMPLEX,

> StaticTextField.class);

> > registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> > registerChild(CHILD_RADIO_COMPLEXITY,

> RadioButtonGroup.class);

> > registerChild(CHILD_HIDDEN_DOCTYPE,

> HiddenField.class);

> > }

> >

> >

> > /**

> > * Create the child objects for the related jsp page. You must

> > register/create

> > * an object for every form element or any element that you'd

> like to

> > support

> > * localization for

> > *

> > * @return a View that represents the element on the jsp page.

> > * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> > */

> > protected View createChild(String name) {

> > if(name.equals(CHILD_LABEL_INTRO)) {

> > StaticTextField child = new StaticTextField(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.intro",

> > "?", null);

> > return child;

> > } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> > RadioButtonGroup child = new RadioButtonGroup(this,

> name,

> > "0");

> > child.setOptions(options);

> > return child;

> > } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> > HiddenField child = new HiddenField(this,

> name, "");

> > return child;

> > } else if(name.equals(CHILD_BUTTON_CREATE)) {

> > CCButton child = new CCButton(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.create",

> > "?", null);

> > return child;

> > } else {

> > throw new IllegalArgumentException("Invalid child name

> > \""+name+"\"");

> > }

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Request event handler methods - mandatory for button and

HREF

> > fields

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > public void handleCreateRequest(RequestInvocationEvent event)

> > throws ServletException, IOException, ClassNotFoundException,

> Exception {

> > try {

> > ViewBean targetView =

> > getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> > targetView.setDisplayFieldValue

> (CHILD_HIDDEN_DOCTYPE,

> > getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

> >

> > targetView.setDisplayFieldValue

> (VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> > getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> > targetView.forwardTo(getRequestContext());

> > } catch(ClassNotFoundException cnfe) {

> > // Will change this when development is

> finished....

> > throw new ClassNotFoundException

> ("VoyagerCreateChoiceViewBean class

> > was not found");

> > } catch(Exception e) {

> > e.printStackTrace();

> > }

> > }

> > }

> >

> >

> >

> >

> >

> >

> >

> > In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

> wrote:

> > > Can we see the JSP and the ViewBean class (the register and

create

> > child

> > > parts at least).

> > >

> > > One observation:

> > > When you do getViewBean(...), you don't have to do Class.forName

> (...),

> > > you can simply do this:

> > > getViewBean(FooViewBean.class)

> > >

> > > Don't know if there is any real performance difference (Todd,

> Mike,

> > > Matt... comments?)

> > > But just seems simpler and no need for literals (the viewbean

> constant).

> > >

> > > craig

> > >

> > >

> > > chubbykidd wrote:

> > >

> > > >I'm having a problem setting a Jato HiddenField. I have a

> combobox on

> > > >page 1 of my app. In my request handler for page 1 I retrieve

the

> > > >value selected from the combobox and I try to set a

HiddenField

> object

> > > >(that resides on page 2 of my app) with the value from the

> combobox.

> > > >Here's my code in my page 1 request handler...

> > > >

> > > >ViewBean targetView =

> > > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > > >System.out.println("***********************"+

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

> +"********************");

> > > >

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > > >targetView.forwardTo(getRequestContext());

> > > >

> > > >In the System.out.println() statement, I'm getting the correct

> value

> > > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason

the

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > > >HiddenField object for the following page

> > > >(VoyagerCreateChoiceViewBean).

> > > >

> > > >Any idea as to what I'm doing wrong?

> > > >

> > > >I've put a print statement before and after the

registerChildren

> ()

> > > >method that resides in my page 2 ViewBean

> > > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

> try and

> > > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

> HiddenFiled

> > > >object that resides on page 2 of my app.

> > > >

> > > >- Billy -

> > > >

> > > >

> > > >

> > > >

> > > >To download the latest version of JATO, please visit:

> > > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > > >

> > > >For more information about JATO, please visit:

> > > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > > >

> > > >

> > > >

> > > >

> > > >

> > > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 6

Hi Chubby

I tried the same scenario again on my machine and it works fine.

I am setting the values while I am on one page and then forward to

the other viewbean which contains the child elements for which I have

set the values.

I can send you my samples if it helps..

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "pavan vangara" <<a href="/group/SunONE-JATO/post?protectID=081166234108158209169212055140064253000 032044067209130152">vangara_pavank@y...</a>> wrote:

> Hi Chubby

> Try the following:

>

> ((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

> .setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

>

> Hope this works,

>

> Pavan

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> > I've embedded the jsp and ViewBean in this e-mail. If it's

difficult

> > to read, let me know if I can e-mail the two files to you....

> >

> >

> > Here is my jsp page that has the HiddenField within the form.....

> >

> >

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> > <jato:useViewBean

> >

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

> an">

> > <%--

> > NOTE: The following declaration is only necessary if you are

using

> the

> > TEI taglib workaround

> > (which is enabled by default). See the JATO Tag Library

> > documentation for complete

> > information.

> > --%>

> > <jsp:useBean id="viewBean"

> >

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> > <!-- Define the resource bundle, html, head, meta, stylesheet and

> body

> > tags -->

> > <cc:header pageTitle="Voyager Create Document Complexity"

> > copyrightYear="2002"

> > baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> > bundleID="myBundle">

> > <script src="/voyager/js/voyager.js"></script>

> > <%-- Include Masthead With Tabs --%>

> > <jsp:include page="VoyagerHeader.jsp" flush="true" />

> > <jato:form name="VoyagerCreateChoice" method="post">

> > <jato:hidden name="doctype" />

> > <table align="left" cellpadding="3" cellspacing="3" border="0"

> > width="600">

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left" class="plaintxt"><jato:text

> > name="intro_label" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"

> class="plaintxt"><jato:radioButtons

> > name="complexity" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"> </td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"><cc:button

name="create" /></td>

> > </tr>

> > </table>

> > </jato:form>

> > </cc:header>

> > </jato:useViewBean>

> >

> >

--

> --

> >

> > Here is my ViewBean associated to the jsp page above...

> >

> > package com.sun.cms.voyager.voyagermodule;

> >

> > import java.io.*;

> > import java.lang.reflect.*;

> > import java.sql.*;

> > import java.util.*;

> > import javax.servlet.*;

> > import javax.servlet.http.*;

> >

> > import com.sun.cms.fw.*;

> > import com.sun.cms.voyager.voyagermodule.*;

> >

> > import com.iplanet.jato.*;

> > import com.iplanet.jato.model.*;

> > import com.iplanet.jato.model.sql.*;

> > import com.iplanet.jato.util.*;

> > import com.iplanet.jato.view.*;

> > import com.iplanet.jato.view.event.*;

> > import com.iplanet.jato.view.html.*;

> >

> > import com.sun.web.ui.view.html.*;

> >

> > /**

> > * This class represents the Create Choice screen that

> > * follows when a user chooses to create a document

> > *

> > * @author Billy Bacon

> > */

> > public class VoyagerCreateChoiceViewBean extends

VoyagerViewBeanBase

> > implements IVoyagerConstants {

> >

> > // Mandatory members

> > // The "logical" name for this page.

> > public static final String PAGE_NAME =

> VOYAGER_CREATE_CHOICE_PAGE;

> >

> > // The URL that points to the JSP which uses this ViewBean

> > public static final String DEFAULT_DISPLAY_URL =

> > "/voyager/"+PAGE_NAME+".jsp";

> >

> > // Recommended members

> > // String constants for child field names. This is simply

good

> > coding practice

> > // to minimize use of string literals.

> > public static final String CHILD_LABEL_INTRO

> = "intro_label";

> > public static final String CHILD_LABEL_SIMPLE

> = "simple_label";

> > public static final String CHILD_LABEL_COMPLEX

> = "complex_label";

> > public static final String CHILD_RADIO_COMPLEXITY

> = "complexity";

> > public static final String CHILD_HIDDEN_DOCTYPE

> = "doctype";

> > public static final String CHILD_BUTTON_CREATE

= "create";

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> > // Instance variables

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> >

> > // Model instance references - optional, recommended

> > // (See Model accessors & mutators above)

> > // NOTE: Do NOT create instance variables that refer to child

> > views (i.e. display fields)

> > // Instead create accessors according to the examples above

> >

> > //private VoyagerHomeSummaryModel homeSummaryModel = null;

> > //private VoyagerToDoModel toDoModel

> = null;

> > //private VoyagerDraftModel draftModel = null;

> > //private VoyagerMyDocsModelmyDocsModel = null;

> >

> > // The first string array are the labels, the second string

> array

> > are the values.

> > // This list populates the RadioButtonGroup for document type

> > complexity.

> > private static OptionList options = new OptionList(new String

[]

> > {"Simple Document", "Complex Document"}, new String[]{"simple",

> > "complex"});

> >

> > /**

> > * Default constructor

> > *

> > */

> > public VoyagerCreateChoiceViewBean() {

> > super(PAGE_NAME);

> > setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> > registerChildren();

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Child methods - mandatory

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > /**

> > *

> > *

> > */

> > protected void registerChildren() {

> > // Add an entry for each child. Note, the children

> are not instantiated

> > // at this time. Instead, child instantiation is

> handled in a lazy

> > fashion.

> > registerChild(CHILD_LABEL_INTRO,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_SIMPLE,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_COMPLEX,

> StaticTextField.class);

> > registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> > registerChild(CHILD_RADIO_COMPLEXITY,

> RadioButtonGroup.class);

> > registerChild(CHILD_HIDDEN_DOCTYPE,

> HiddenField.class);

> > }

> >

> >

> > /**

> > * Create the child objects for the related jsp page. You must

> > register/create

> > * an object for every form element or any element that you'd

> like to

> > support

> > * localization for

> > *

> > * @return a View that represents the element on the jsp page.

> > * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> > */

> > protected View createChild(String name) {

> > if(name.equals(CHILD_LABEL_INTRO)) {

> > StaticTextField child = new StaticTextField(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.intro",

> > "?", null);

> > return child;

> > } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> > RadioButtonGroup child = new RadioButtonGroup(this,

> name,

> > "0");

> > child.setOptions(options);

> > return child;

> > } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> > HiddenField child = new HiddenField(this,

> name, "");

> > return child;

> > } else if(name.equals(CHILD_BUTTON_CREATE)) {

> > CCButton child = new CCButton(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.create",

> > "?", null);

> > return child;

> > } else {

> > throw new IllegalArgumentException("Invalid child name

> > \""+name+"\"");

> > }

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Request event handler methods - mandatory for button and

HREF

> > fields

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > public void handleCreateRequest(RequestInvocationEvent event)

> > throws ServletException, IOException, ClassNotFoundException,

> Exception {

> > try {

> > ViewBean targetView =

> > getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> > targetView.setDisplayFieldValue

> (CHILD_HIDDEN_DOCTYPE,

> > getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

> >

> > targetView.setDisplayFieldValue

> (VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> > getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> > targetView.forwardTo(getRequestContext());

> > } catch(ClassNotFoundException cnfe) {

> > // Will change this when development is

> finished....

> > throw new ClassNotFoundException

> ("VoyagerCreateChoiceViewBean class

> > was not found");

> > } catch(Exception e) {

> > e.printStackTrace();

> > }

> > }

> > }

> >

> >

> >

> >

> >

> >

> >

> > In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

> wrote:

> > > Can we see the JSP and the ViewBean class (the register and

create

> > child

> > > parts at least).

> > >

> > > One observation:

> > > When you do getViewBean(...), you don't have to do Class.forName

> (...),

> > > you can simply do this:

> > > getViewBean(FooViewBean.class)

> > >

> > > Don't know if there is any real performance difference (Todd,

> Mike,

> > > Matt... comments?)

> > > But just seems simpler and no need for literals (the viewbean

> constant).

> > >

> > > craig

> > >

> > >

> > > chubbykidd wrote:

> > >

> > > >I'm having a problem setting a Jato HiddenField. I have a

> combobox on

> > > >page 1 of my app. In my request handler for page 1 I retrieve

the

> > > >value selected from the combobox and I try to set a

HiddenField

> object

> > > >(that resides on page 2 of my app) with the value from the

> combobox.

> > > >Here's my code in my page 1 request handler...

> > > >

> > > >ViewBean targetView =

> > > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > > >System.out.println("***********************"+

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

> +"********************");

> > > >

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > > >targetView.forwardTo(getRequestContext());

> > > >

> > > >In the System.out.println() statement, I'm getting the correct

> value

> > > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason

the

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > > >HiddenField object for the following page

> > > >(VoyagerCreateChoiceViewBean).

> > > >

> > > >Any idea as to what I'm doing wrong?

> > > >

> > > >I've put a print statement before and after the

registerChildren

> ()

> > > >method that resides in my page 2 ViewBean

> > > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

> try and

> > > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

> HiddenFiled

> > > >object that resides on page 2 of my app.

> > > >

> > > >- Billy -

> > > >

> > > >

> > > >

> > > >

> > > >To download the latest version of JATO, please visit:

> > > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > > >

> > > >For more information about JATO, please visit:

> > > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > > >

> > > >

> > > >

> > > >

> > > >

> > > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...
# 7

Hi Chubby

I tried the same scenario again on my machine and it works fine.

I am setting the values while I am on one page and then forward to

the other viewbean which contains the child elements for which I have

set the values.

I can send you my samples if it helps..

Pavan

In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "pavan vangara" <<a href="/group/SunONE-JATO/post?protectID=081166234108158209169212055140064253000 032044067209130152">vangara_pavank@y...</a>> wrote:

> Hi Chubby

> Try the following:

>

> ((HiddenField)targetView.getChild(CHILD_HIDDEN_DOCTYPE))

> .setValue(getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

>

> Hope this works,

>

> Pavan

>

> In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "chubbykidd" <<a href="/group/SunONE-JATO/post?protectID=014166219007078048234218065036129208"&g t;bacon33@o...</a>> wrote:

> > I've embedded the jsp and ViewBean in this e-mail. If it's

difficult

> > to read, let me know if I can e-mail the two files to you....

> >

> >

> > Here is my jsp page that has the HiddenField within the form.....

> >

> >

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="VoyagerCreateChoice" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/jato.tld" prefix="jato"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/lib/cc.tld" prefix="cc"%>

> > <jato:useViewBean

> >

>

className="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBe

> an">

> > <%--

> > NOTE: The following declaration is only necessary if you are

using

> the

> > TEI taglib workaround

> > (which is enabled by default). See the JATO Tag Library

> > documentation for complete

> > information.

> > --%>

> > <jsp:useBean id="viewBean"

> >

>

type="com.sun.cms.voyager.voyagermodule.VoyagerCreateChoiceViewBean"/>

> > <!-- Define the resource bundle, html, head, meta, stylesheet and

> body

> > tags -->

> > <cc:header pageTitle="Voyager Create Document Complexity"

> > copyrightYear="2002"

> > baseName="com.sun.cms.voyager.voyagermodule.resources.Resources"

> > bundleID="myBundle">

> > <script src="/voyager/js/voyager.js"></script>

> > <%-- Include Masthead With Tabs --%>

> > <jsp:include page="VoyagerHeader.jsp" flush="true" />

> > <jato:form name="VoyagerCreateChoice" method="post">

> > <jato:hidden name="doctype" />

> > <table align="left" cellpadding="3" cellspacing="3" border="0"

> > width="600">

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left" class="plaintxt"><jato:text

> > name="intro_label" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"

> class="plaintxt"><jato:radioButtons

> > name="complexity" /></td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"> </td>

> > </tr>

> > <tr>

> > <td width="125"> </td>

> > <td width="*" align="left"><cc:button

name="create" /></td>

> > </tr>

> > </table>

> > </jato:form>

> > </cc:header>

> > </jato:useViewBean>

> >

> >

--

> --

> >

> > Here is my ViewBean associated to the jsp page above...

> >

> > package com.sun.cms.voyager.voyagermodule;

> >

> > import java.io.*;

> > import java.lang.reflect.*;

> > import java.sql.*;

> > import java.util.*;

> > import javax.servlet.*;

> > import javax.servlet.http.*;

> >

> > import com.sun.cms.fw.*;

> > import com.sun.cms.voyager.voyagermodule.*;

> >

> > import com.iplanet.jato.*;

> > import com.iplanet.jato.model.*;

> > import com.iplanet.jato.model.sql.*;

> > import com.iplanet.jato.util.*;

> > import com.iplanet.jato.view.*;

> > import com.iplanet.jato.view.event.*;

> > import com.iplanet.jato.view.html.*;

> >

> > import com.sun.web.ui.view.html.*;

> >

> > /**

> > * This class represents the Create Choice screen that

> > * follows when a user chooses to create a document

> > *

> > * @author Billy Bacon

> > */

> > public class VoyagerCreateChoiceViewBean extends

VoyagerViewBeanBase

> > implements IVoyagerConstants {

> >

> > // Mandatory members

> > // The "logical" name for this page.

> > public static final String PAGE_NAME =

> VOYAGER_CREATE_CHOICE_PAGE;

> >

> > // The URL that points to the JSP which uses this ViewBean

> > public static final String DEFAULT_DISPLAY_URL =

> > "/voyager/"+PAGE_NAME+".jsp";

> >

> > // Recommended members

> > // String constants for child field names. This is simply

good

> > coding practice

> > // to minimize use of string literals.

> > public static final String CHILD_LABEL_INTRO

> = "intro_label";

> > public static final String CHILD_LABEL_SIMPLE

> = "simple_label";

> > public static final String CHILD_LABEL_COMPLEX

> = "complex_label";

> > public static final String CHILD_RADIO_COMPLEXITY

> = "complexity";

> > public static final String CHILD_HIDDEN_DOCTYPE

> = "doctype";

> > public static final String CHILD_BUTTON_CREATE

= "create";

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> > // Instance variables

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////

> >

> > // Model instance references - optional, recommended

> > // (See Model accessors & mutators above)

> > // NOTE: Do NOT create instance variables that refer to child

> > views (i.e. display fields)

> > // Instead create accessors according to the examples above

> >

> > //private VoyagerHomeSummaryModel homeSummaryModel = null;

> > //private VoyagerToDoModel toDoModel

> = null;

> > //private VoyagerDraftModel draftModel = null;

> > //private VoyagerMyDocsModelmyDocsModel = null;

> >

> > // The first string array are the labels, the second string

> array

> > are the values.

> > // This list populates the RadioButtonGroup for document type

> > complexity.

> > private static OptionList options = new OptionList(new String

[]

> > {"Simple Document", "Complex Document"}, new String[]{"simple",

> > "complex"});

> >

> > /**

> > * Default constructor

> > *

> > */

> > public VoyagerCreateChoiceViewBean() {

> > super(PAGE_NAME);

> > setDefaultDisplayURL(DEFAULT_DISPLAY_URL);

> > registerChildren();

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Child methods - mandatory

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > /**

> > *

> > *

> > */

> > protected void registerChildren() {

> > // Add an entry for each child. Note, the children

> are not instantiated

> > // at this time. Instead, child instantiation is

> handled in a lazy

> > fashion.

> > registerChild(CHILD_LABEL_INTRO,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_SIMPLE,

> StaticTextField.class);

> > registerChild(CHILD_LABEL_COMPLEX,

> StaticTextField.class);

> > registerChild(CHILD_BUTTON_CREATE, CCButton.class);

> > registerChild(CHILD_RADIO_COMPLEXITY,

> RadioButtonGroup.class);

> > registerChild(CHILD_HIDDEN_DOCTYPE,

> HiddenField.class);

> > }

> >

> >

> > /**

> > * Create the child objects for the related jsp page. You must

> > register/create

> > * an object for every form element or any element that you'd

> like to

> > support

> > * localization for

> > *

> > * @return a View that represents the element on the jsp page.

> > * @author Billy Bacon (<a href="/group/SunONE-JATO/post?protectID=014176235078196091180098141024006165163 048139046">billy.bacon@s...</a>)

> > */

> > protected View createChild(String name) {

> > if(name.equals(CHILD_LABEL_INTRO)) {

> > StaticTextField child = new StaticTextField(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.intro",

> > "?", null);

> > return child;

> > } else if(name.equals(CHILD_RADIO_COMPLEXITY)) {

> > RadioButtonGroup child = new RadioButtonGroup(this,

> name,

> > "0");

> > child.setOptions(options);

> > return child;

> > } else if(name.equals(CHILD_HIDDEN_DOCTYPE)) {

> > HiddenField child = new HiddenField(this,

> name, "");

> > return child;

> > } else if(name.equals(CHILD_BUTTON_CREATE)) {

> > CCButton child = new CCButton(this,

> > getResourceBundleModel(Locale.ENGLISH),

name, "createchoice.create",

> > "?", null);

> > return child;

> > } else {

> > throw new IllegalArgumentException("Invalid child name

> > \""+name+"\"");

> > }

> > }

> >

> >

> >

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> > // Request event handler methods - mandatory for button and

HREF

> > fields

> >

>

> ////////////////////////////////////////////////////////////////////

> ////////////

> >

> > public void handleCreateRequest(RequestInvocationEvent event)

> > throws ServletException, IOException, ClassNotFoundException,

> Exception {

> > try {

> > ViewBean targetView =

> > getViewBean(Class.forName(VOYAGER_CREATE_VIEWBEAN));

> > targetView.setDisplayFieldValue

> (CHILD_HIDDEN_DOCTYPE,

> > getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE));

> >

> > targetView.setDisplayFieldValue

> (VoyagerCreateViewBean.CHILD_HIDDEN_COMPLEXITY,

> > getDisplayFieldValue(CHILD_RADIO_COMPLEXITY));

> > targetView.forwardTo(getRequestContext());

> > } catch(ClassNotFoundException cnfe) {

> > // Will change this when development is

> finished....

> > throw new ClassNotFoundException

> ("VoyagerCreateChoiceViewBean class

> > was not found");

> > } catch(Exception e) {

> > e.printStackTrace();

> > }

> > }

> > }

> >

> >

> >

> >

> >

> >

> >

> > In <a href="/group/SunONE-JATO/post?protectID=246075234167171124217231170221059165026 048139046">SunONE-JATO@y...</a>, "Craig V. Conover" <<a href="/group/SunONE-JATO/post?protectID=219212113009229091025149066024064239039 098031046209130">craig.conover@s...</a>>

> wrote:

> > > Can we see the JSP and the ViewBean class (the register and

create

> > child

> > > parts at least).

> > >

> > > One observation:

> > > When you do getViewBean(...), you don't have to do Class.forName

> (...),

> > > you can simply do this:

> > > getViewBean(FooViewBean.class)

> > >

> > > Don't know if there is any real performance difference (Todd,

> Mike,

> > > Matt... comments?)

> > > But just seems simpler and no need for literals (the viewbean

> constant).

> > >

> > > craig

> > >

> > >

> > > chubbykidd wrote:

> > >

> > > >I'm having a problem setting a Jato HiddenField. I have a

> combobox on

> > > >page 1 of my app. In my request handler for page 1 I retrieve

the

> > > >value selected from the combobox and I try to set a

HiddenField

> object

> > > >(that resides on page 2 of my app) with the value from the

> combobox.

> > > >Here's my code in my page 1 request handler...

> > > >

> > > >ViewBean targetView =

> > > >getViewBean(Class.forName(VOYAGER_CREATE_CHOICE_VIEWBEAN));

> > > >System.out.println("***********************"+

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)

> +"********************");

> > > >

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE));

> > > >targetView.forwardTo(getRequestContext());

> > > >

> > > >In the System.out.println() statement, I'm getting the correct

> value

> > > >from the combobox (CHILD_MENU_DOC_TYPE). But for some reason

the

> > > >targetView.setDisplayFieldValue(VoyagerCreateChoic

> > > >eViewBean.CHILD_HIDDEN_DOCTYPE,

> > > >getDisplayFieldValue(CHILD_MENU_DOC_TYPE)); is not setting the

> > > >HiddenField object for the following page

> > > >(VoyagerCreateChoiceViewBean).

> > > >

> > > >Any idea as to what I'm doing wrong?

> > > >

> > > >I've put a print statement before and after the

registerChildren

> ()

> > > >method that resides in my page 2 ViewBean

> > > >(VoyagerCreateChoiceViewBean) and I get a *null* value when I

> try and

> > > >getDisplayFieldValue(CHILD_HIDDEN_DOCTYPE). This is the

> HiddenFiled

> > > >object that resides on page 2 of my app.

> > > >

> > > >- Billy -

> > > >

> > > >

> > > >

> > > >

> > > >To download the latest version of JATO, please visit:

> > > ><a href="http://www.sun.com/software/download/developer/5102.html">http://www.s un.com/software/download/developer/5102.html</a>

> > > >

> > > >For more information about JATO, please visit:

> > > ><a href="http://developer.iplanet.com/tech/appserver/framework/index.jsp">http: //developer.iplanet.com/tech/appserver/framework/index.jsp</a>

> > > >

> > > >

> > > >

> > > >

> > > >

> > > >

Guest at 2007-7-1 16:31:30 > top of Java-index,Development Tools,Java Tools...