You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rosemary Philip <ro...@gmail.com> on 2004/10/18 04:47:39 UTC

html:hidden values are null

I am having a problem getting values to another page when I try to use
html:hidden.

I have a list of employee objects in a page. on clicking on an
employee from the list, the next page should show me more details on
the employee.
for getting the values across, i am trying to use html:hidden. but for
some reason i am getting null for the attributes.

when i do a view source on the page with the list, this is what i see.

<TR class="command" 					onclick='window.location="./empDetailPrepare.do"'	>

	<input type="hidden" name="empNmbr" value="8423">		
	<input type="hidden" name="empSSN" value="55315">		
	
	<TD class="list">Howard Austin</TD>
       <TD class="list">Programmer</TD>


The employee list shows the name and job title of the employee and I
am passing  empNmbr and empSSN as the hidden parameters.

I have a EmplListForm (ActionForm)  which has empNmbr and empSSN as
the attributes. I have a Value Object Employee , which has a bunch of
attributes like empNmbr,empSSN,name,jobTitle etc.
---------------------------------------------------------------
struts-config.xml

<!--*** emp list form bean, just used to pass some properties to the
next page***-->
<form-bean name="empListbean" type="com.test.web.forms.empListForm">
</form-bean>		

<!--*** show the emp list ***-->
<action path="/showempList"  type="com.test.web.actions.EmpListAction"
name="empListbean" scope="request">
	<forward name="empdetailprepare" path="/empDetailPrepare.do"/>
</action>
		
<!--*** prepares the event detail screen for display ***-->
<action path="/empDetailPrepare" 
type="com.test.web.actions.EmpDetailsPrepareAction" name="empListbean"
scope="request">
	<forward name="continue" path="/empDetail.jsp"/>
		</action>

--------------------------
empList.jsp

<html:hidden name='empobj' property='empNmbr'/>		
<html:hidden name='empobj' property='evntTm'/>
	
<TD class="list"><bean:write name='empobj' property='name' /></TD>
<TD class="list"><bean:write name='empobj' property='jobTitle' /></TD>

--------------------------------------
in my action class

EmplListForm emplListForm = (EmplListForm ) form;
System.out.println("empNmbr = "+request.getAttribute("empNmbr"));

------------------------------------------------------------------------
I am at a loss at to what am I missing here. Can anyone point out anything?
Thanks,
Rosemary

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:hidden values are null

Posted by Rosemary Philip <ro...@gmail.com>.
David,

same here. a long weary day. :)

the info you shared about onClick is new to me.

I discussed this problem with a developer and he said that this values
come null because there are more than one objects of the same kind.
i.e, in an employee list there are more than one employees and since I
have

 <TD class="list"><bean:write name='empobj' property='name' /></TD>

in my jsp, it is getting confused and doesnt know which value ( of
which object) to carry across. Do you think this is the case? So how
he has implemented is by tagging an index onto the selected object in
the arraylist(which is being iterated) and comparing the original
arraylist that he sent in the request(to be displayed in the page) to
the one returned from the page.
I understood the concept but am yet to understand how he implemented it. 

All this problems has befallen me because I am using the valueobject
and it has a TimeValue attribute, which is very big.
<bean:write name='empobj' property='joinTime' /> always gives me
javascript errors saying " ; " is missing or something. the same with
hidden values.

Another idea that a friend gave me is to not use the value object
directlty to write to the page. rather create another object where all
the fields are String and pass that across the pages, so that it will
just be form.getAttribute() in my action.

I am confused. wading through code now. thanks for your input.

On Mon, 18 Oct 2004 23:31:24 -0400, David G. Friedman
<hu...@ix.netcom.com> wrote:
> Rosemary,
> 
> I had a long day at work so bear with me..
> 
> Are you using the JavaScript 'onClick' event to go to the new form which is
> resulting in missing hidden fields?  If so, that is your problem:
> 
> It isn't changing the action on the from (And then submitting the form) but
> changing the web page in the browser directly using window.location.  That
> ignores all forms on the page and acts as if you typed the URL in the
> browser's location text box/window.  I believe you would want to change the
> onClick to do something like this:
> 
> onClick="javascript:this.form.action=\"./empDetailPrepare.do\";this.form.sub
> mit();"
> 
> My javascript might be slightly off but I'm definitely about there.  This
> would result in the onClick event changing the form's submit location and
> then submitting the form.  Any variables, hidden or visible, would be
> submitted to the new Struts action.
> 
> Regards,
> David
> 
> -----Original Message-----
> From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
> Sent: Monday, October 18, 2004 9:13 AM
> To: user@struts.apache.org
> Cc: humble@ix.netcom.com
> Subject: Re: html:hidden values are null
> 
> Yes, the html:hidden is within an html:form. Also when I do a view
> source on the page, I can see the values of the hidden variables
> correctly.
> but when I trace them to action class, they are null, all of them.
> 
> another thing. this is what my html:form tag in my first jsp page says.
> <html:form action="/showempList" method="post">
> 
> but in the same page I have this <TR class="command"
>                  onclick='window.location="./empDetailPrepare.do"'
>   > ,
> which goes to a different action. I dont know enough about Struts to
> know if this is a problem. There is a similar logic in another set of
> pages where , both are the same. I meant both actions are the same and
> that works.
> 
> On Mon, 18 Oct 2004 00:01:51 -0400, David G. Friedman
> <hu...@ix.netcom.com> wrote:
> > Are you positive you have the html:hidden tag
> > within the appropriate html:form tag?  What is
> > your html:form tag for either JSP?
> >
> > Regards,
> > David
> >
> >
> >
> > -----Original Message-----
> > From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
> > Sent: Sunday, October 17, 2004 10:48 PM
> > To: user@struts.apache.org
> > Subject: html:hidden values are null
> >
> > I am having a problem getting values to another page when I try to use
> > html:hidden.
> >
> > I have a list of employee objects in a page. on clicking on an
> > employee from the list, the next page should show me more details on
> > the employee.
> > for getting the values across, i am trying to use html:hidden. but for
> > some reason i am getting null for the attributes.
> >
> > when i do a view source on the page with the list, this is what i see.
> >
> > <TR class="command"
> onclick='window.location="./empDetailPrepare.do"'       >
> >
> >        <input type="hidden" name="empNmbr" value="8423">
> >        <input type="hidden" name="empSSN" value="55315">
> >
> >        <TD class="list">Howard Austin</TD>
> >       <TD class="list">Programmer</TD>
> >
> > The employee list shows the name and job title of the employee and I
> > am passing  empNmbr and empSSN as the hidden parameters.
> >
> > I have a EmplListForm (ActionForm)  which has empNmbr and empSSN as
> > the attributes. I have a Value Object Employee , which has a bunch of
> > attributes like empNmbr,empSSN,name,jobTitle etc.
> > ---------------------------------------------------------------
> > struts-config.xml
> >
> > <!--*** emp list form bean, just used to pass some properties to the
> > next page***-->
> > <form-bean name="empListbean" type="com.test.web.forms.empListForm">
> > </form-bean>
> >
> > <!--*** show the emp list ***-->
> > <action path="/showempList"  type="com.test.web.actions.EmpListAction"
> > name="empListbean" scope="request">
> >        <forward name="empdetailprepare" path="/empDetailPrepare.do"/>
> > </action>
> >
> > <!--*** prepares the event detail screen for display ***-->
> > <action path="/empDetailPrepare"
> > type="com.test.web.actions.EmpDetailsPrepareAction" name="empListbean"
> > scope="request">
> >        <forward name="continue" path="/empDetail.jsp"/>
> >                </action>
> >
> > --------------------------
> > empList.jsp
> >
> > <html:hidden name='empobj' property='empNmbr'/>
> > <html:hidden name='empobj' property='evntTm'/>
> >
> > <TD class="list"><bean:write name='empobj' property='name' /></TD>
> > <TD class="list"><bean:write name='empobj' property='jobTitle' /></TD>
> >
> > --------------------------------------
> > in my action class
> >
> > EmplListForm emplListForm = (EmplListForm ) form;
> > System.out.println("empNmbr = "+request.getAttribute("empNmbr"));
> >
> > ------------------------------------------------------------------------
> > I am at a loss at to what am I missing here. Can anyone point out
> anything?
> > Thanks,
> > Rosemary
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> 
> 
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: html:hidden values are null

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Rosemary,

I had a long day at work so bear with me..

Are you using the JavaScript 'onClick' event to go to the new form which is
resulting in missing hidden fields?  If so, that is your problem:

It isn't changing the action on the from (And then submitting the form) but
changing the web page in the browser directly using window.location.  That
ignores all forms on the page and acts as if you typed the URL in the
browser's location text box/window.  I believe you would want to change the
onClick to do something like this:

onClick="javascript:this.form.action=\"./empDetailPrepare.do\";this.form.sub
mit();"

My javascript might be slightly off but I'm definitely about there.  This
would result in the onClick event changing the form's submit location and
then submitting the form.  Any variables, hidden or visible, would be
submitted to the new Struts action.

Regards,
David

-----Original Message-----
From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
Sent: Monday, October 18, 2004 9:13 AM
To: user@struts.apache.org
Cc: humble@ix.netcom.com
Subject: Re: html:hidden values are null


Yes, the html:hidden is within an html:form. Also when I do a view
source on the page, I can see the values of the hidden variables
correctly.
but when I trace them to action class, they are null, all of them.

another thing. this is what my html:form tag in my first jsp page says.
<html:form action="/showempList" method="post">

but in the same page I have this <TR class="command"
                  onclick='window.location="./empDetailPrepare.do"'
   > ,
which goes to a different action. I dont know enough about Struts to
know if this is a problem. There is a similar logic in another set of
pages where , both are the same. I meant both actions are the same and
that works.




On Mon, 18 Oct 2004 00:01:51 -0400, David G. Friedman
<hu...@ix.netcom.com> wrote:
> Are you positive you have the html:hidden tag
> within the appropriate html:form tag?  What is
> your html:form tag for either JSP?
>
> Regards,
> David
>
>
>
> -----Original Message-----
> From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
> Sent: Sunday, October 17, 2004 10:48 PM
> To: user@struts.apache.org
> Subject: html:hidden values are null
>
> I am having a problem getting values to another page when I try to use
> html:hidden.
>
> I have a list of employee objects in a page. on clicking on an
> employee from the list, the next page should show me more details on
> the employee.
> for getting the values across, i am trying to use html:hidden. but for
> some reason i am getting null for the attributes.
>
> when i do a view source on the page with the list, this is what i see.
>
> <TR class="command"
onclick='window.location="./empDetailPrepare.do"'       >
>
>        <input type="hidden" name="empNmbr" value="8423">
>        <input type="hidden" name="empSSN" value="55315">
>
>        <TD class="list">Howard Austin</TD>
>       <TD class="list">Programmer</TD>
>
> The employee list shows the name and job title of the employee and I
> am passing  empNmbr and empSSN as the hidden parameters.
>
> I have a EmplListForm (ActionForm)  which has empNmbr and empSSN as
> the attributes. I have a Value Object Employee , which has a bunch of
> attributes like empNmbr,empSSN,name,jobTitle etc.
> ---------------------------------------------------------------
> struts-config.xml
>
> <!--*** emp list form bean, just used to pass some properties to the
> next page***-->
> <form-bean name="empListbean" type="com.test.web.forms.empListForm">
> </form-bean>
>
> <!--*** show the emp list ***-->
> <action path="/showempList"  type="com.test.web.actions.EmpListAction"
> name="empListbean" scope="request">
>        <forward name="empdetailprepare" path="/empDetailPrepare.do"/>
> </action>
>
> <!--*** prepares the event detail screen for display ***-->
> <action path="/empDetailPrepare"
> type="com.test.web.actions.EmpDetailsPrepareAction" name="empListbean"
> scope="request">
>        <forward name="continue" path="/empDetail.jsp"/>
>                </action>
>
> --------------------------
> empList.jsp
>
> <html:hidden name='empobj' property='empNmbr'/>
> <html:hidden name='empobj' property='evntTm'/>
>
> <TD class="list"><bean:write name='empobj' property='name' /></TD>
> <TD class="list"><bean:write name='empobj' property='jobTitle' /></TD>
>
> --------------------------------------
> in my action class
>
> EmplListForm emplListForm = (EmplListForm ) form;
> System.out.println("empNmbr = "+request.getAttribute("empNmbr"));
>
> ------------------------------------------------------------------------
> I am at a loss at to what am I missing here. Can anyone point out
anything?
> Thanks,
> Rosemary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:hidden values are null

Posted by Rosemary Philip <ro...@gmail.com>.
Yes, the html:hidden is within an html:form. Also when I do a view
source on the page, I can see the values of the hidden variables
correctly.
but when I trace them to action class, they are null, all of them.

another thing. this is what my html:form tag in my first jsp page says.
<html:form action="/showempList" method="post">

but in the same page I have this <TR class="command"                  
                  onclick='window.location="./empDetailPrepare.do"'   
   > ,
which goes to a different action. I dont know enough about Struts to
know if this is a problem. There is a similar logic in another set of
pages where , both are the same. I meant both actions are the same and
that works.




On Mon, 18 Oct 2004 00:01:51 -0400, David G. Friedman
<hu...@ix.netcom.com> wrote:
> Are you positive you have the html:hidden tag
> within the appropriate html:form tag?  What is
> your html:form tag for either JSP?
> 
> Regards,
> David
> 
> 
> 
> -----Original Message-----
> From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
> Sent: Sunday, October 17, 2004 10:48 PM
> To: user@struts.apache.org
> Subject: html:hidden values are null
> 
> I am having a problem getting values to another page when I try to use
> html:hidden.
> 
> I have a list of employee objects in a page. on clicking on an
> employee from the list, the next page should show me more details on
> the employee.
> for getting the values across, i am trying to use html:hidden. but for
> some reason i am getting null for the attributes.
> 
> when i do a view source on the page with the list, this is what i see.
> 
> <TR class="command"                                     onclick='window.location="./empDetailPrepare.do"'       >
> 
>        <input type="hidden" name="empNmbr" value="8423">
>        <input type="hidden" name="empSSN" value="55315">
> 
>        <TD class="list">Howard Austin</TD>
>       <TD class="list">Programmer</TD>
> 
> The employee list shows the name and job title of the employee and I
> am passing  empNmbr and empSSN as the hidden parameters.
> 
> I have a EmplListForm (ActionForm)  which has empNmbr and empSSN as
> the attributes. I have a Value Object Employee , which has a bunch of
> attributes like empNmbr,empSSN,name,jobTitle etc.
> ---------------------------------------------------------------
> struts-config.xml
> 
> <!--*** emp list form bean, just used to pass some properties to the
> next page***-->
> <form-bean name="empListbean" type="com.test.web.forms.empListForm">
> </form-bean>
> 
> <!--*** show the emp list ***-->
> <action path="/showempList"  type="com.test.web.actions.EmpListAction"
> name="empListbean" scope="request">
>        <forward name="empdetailprepare" path="/empDetailPrepare.do"/>
> </action>
> 
> <!--*** prepares the event detail screen for display ***-->
> <action path="/empDetailPrepare"
> type="com.test.web.actions.EmpDetailsPrepareAction" name="empListbean"
> scope="request">
>        <forward name="continue" path="/empDetail.jsp"/>
>                </action>
> 
> --------------------------
> empList.jsp
> 
> <html:hidden name='empobj' property='empNmbr'/>
> <html:hidden name='empobj' property='evntTm'/>
> 
> <TD class="list"><bean:write name='empobj' property='name' /></TD>
> <TD class="list"><bean:write name='empobj' property='jobTitle' /></TD>
> 
> --------------------------------------
> in my action class
> 
> EmplListForm emplListForm = (EmplListForm ) form;
> System.out.println("empNmbr = "+request.getAttribute("empNmbr"));
> 
> ------------------------------------------------------------------------
> I am at a loss at to what am I missing here. Can anyone point out anything?
> Thanks,
> Rosemary
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: html:hidden values are null

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Are you positive you have the html:hidden tag
within the appropriate html:form tag?  What is
your html:form tag for either JSP?

Regards,
David

-----Original Message-----
From: Rosemary Philip [mailto:rosemaryphilip@gmail.com]
Sent: Sunday, October 17, 2004 10:48 PM
To: user@struts.apache.org
Subject: html:hidden values are null


I am having a problem getting values to another page when I try to use
html:hidden.

I have a list of employee objects in a page. on clicking on an
employee from the list, the next page should show me more details on
the employee.
for getting the values across, i am trying to use html:hidden. but for
some reason i am getting null for the attributes.

when i do a view source on the page with the list, this is what i see.

<TR class="command" 					onclick='window.location="./empDetailPrepare.do"'	>

	<input type="hidden" name="empNmbr" value="8423">
	<input type="hidden" name="empSSN" value="55315">

	<TD class="list">Howard Austin</TD>
       <TD class="list">Programmer</TD>


The employee list shows the name and job title of the employee and I
am passing  empNmbr and empSSN as the hidden parameters.

I have a EmplListForm (ActionForm)  which has empNmbr and empSSN as
the attributes. I have a Value Object Employee , which has a bunch of
attributes like empNmbr,empSSN,name,jobTitle etc.
---------------------------------------------------------------
struts-config.xml

<!--*** emp list form bean, just used to pass some properties to the
next page***-->
<form-bean name="empListbean" type="com.test.web.forms.empListForm">
</form-bean>

<!--*** show the emp list ***-->
<action path="/showempList"  type="com.test.web.actions.EmpListAction"
name="empListbean" scope="request">
	<forward name="empdetailprepare" path="/empDetailPrepare.do"/>
</action>

<!--*** prepares the event detail screen for display ***-->
<action path="/empDetailPrepare"
type="com.test.web.actions.EmpDetailsPrepareAction" name="empListbean"
scope="request">
	<forward name="continue" path="/empDetail.jsp"/>
		</action>

--------------------------
empList.jsp

<html:hidden name='empobj' property='empNmbr'/>
<html:hidden name='empobj' property='evntTm'/>

<TD class="list"><bean:write name='empobj' property='name' /></TD>
<TD class="list"><bean:write name='empobj' property='jobTitle' /></TD>

--------------------------------------
in my action class

EmplListForm emplListForm = (EmplListForm ) form;
System.out.println("empNmbr = "+request.getAttribute("empNmbr"));

------------------------------------------------------------------------
I am at a loss at to what am I missing here. Can anyone point out anything?
Thanks,
Rosemary

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org