thanks Robert:

I don't feel so bad.    I was stuck for 3 hours on this doggone dilema (not
to mention a little bit of cussing) and tried quite a few things prior to
my final solution of the intermediate JSP to set the property...    I did
not think that setting a form object's values from html/javascript was
going to be *this* difficult.    If there was a way to force a form
object's values to be loaded without having to do a submit in javascript,
my problem would have been solved.    This was one of those things where I
thought it would take me 5-10 minutes to do and ended up being 3 hours.
Adding the "intermediate" JSP seemed to be a "hack" at first but based on
what you just told me, I guess it's a normal thing  :-)    It works now and
it works beautifully but it sure is alot harder to do then when the screen
was in a JTabbedPane using Swing  :-)

thanks,
Theron



                                                                                       
                 
                    Robert Nocera                                                      
                 
                    <rnocera@neos        To:     Struts Users Mailing List             
                 
                    llc.com>             <[EMAIL PROTECTED]>              
                 
                                         cc:                                           
                 
                    03/11/02             Subject:     RE: Found Solution to setting 
server side parm in 
                    11:16 AM             Javascript BUT....                            
                 
                    Please                                                             
                 
                    respond to                                                         
                 
                    Struts Users                                                       
                 
                    Mailing List                                                       
                 
                                                                                       
                 
                                                                                       
                 



Theron,

There isn't an easier way because a FormBean is a server-side object.
You might think that your html page has access to it, but it's only
because of the sleight of hand involved in JSP programming.  Since a JSP
is actually a servlet, it is only sending HTML to a browser so your
browser knows nothing of these objects.

Robert Nocera
New England Open Solutions
www.neosllc.com
"You supply the vision, we'll do the rest."


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 10, 2002 7:21 PM
To: Struts Users Mailing List
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Found Solution to setting server side parm in Javascript
BUT....


After spending 2 hours trying to find a solution to this, I found one by
trial and error...
BUT THERE HAS GOT TO BE A BETTER WAY  :-)

Here's what I did but I can't believe it's "this" difficult to do...

Here's my checkfield property that needs to "force a form value to be
updated":

                         <html:select property="psdProductType" size="1"
                              onchange="setCurrProductType(this.value)">
                              <html:options collection="psbusinesstype"
property="value"
                                   labelProperty="label"/>
                         </html:select>

Here's the javascript function:

     function setCurrProductType(inProductType) {
          alert("Setting curr product type to: " + inProductType);
          window.location="SetProperty.jsp?enteredPt="+inProductType;
     }

----
and here's the SetProperty.jsp
-----------------------------
<%@ taglib uri="/struts-bean" prefix="bean" %>

<bean:define id="psInfo" name="psSession" type="express.EBPsSession"
scope
="session" />
<bean:define id="psForm" name="psForm" type="express.psForm" scope
="session" />

<%
     //
     // If they changed the product type on the first page, set it
     // here in the form object...
     //
     String sCurrProductType=request.getParameter("enteredPt");
     psInfo.setCurrProductType(sCurrProductType);
     System.out.println("Current Product Type = " +
psInfo.getCurrProductType()
          + " current page = " + psInfo.getCurrpage());
     psForm.setPsdProductType(psInfo.getCurrProductType());
%>

<jsp:forward page="PsPage.jsp"/>
--------------------

So in essence, the "forward" tag simply causes control to come back to
the
page I was on...   But in-between, I was able to set a form bean
property....    Again my problem is the form bean property is not
updated
until you hit the submit button...   In this case, I don't want a submit
to
occur when you change the contents of the dropdown.   Only the property
for
that drop down should change...   After adding this, when I click to go
to
the 4th tab, the action now sees the newly changed value....

It works BUT I have to believe there's a better way!!!    I open to any
suggestions...





                    theron.kousek

                    @webmd.net           To:     Struts Users Mailing
List

<[EMAIL PROTECTED]>
                    03/10/02             cc:

                    02:32 PM             Subject:     setting server
side parm in Javascript?
                    Please

                    respond to

                    Struts Users

                    Mailing List









Hi Folks:

I'm doing a mimic-JTabbedPane approach.   I have a screen with 5 tabs.
I
am using 1 form object and 5 action mappings...

On tab 4, I'd like to detect changes made to a field on tab 1.     I
notice
I can change the field on tab 1 but tab 4 does not know about until the
form is submitted.    I can't submit the form...

I'd like to have a Javascript handler that implements the onchange() and
somehow sets a session attribute or some kind of trigger that tells tab
4
to "reload" itself when this field on tab 1 has changed.    I notice if
I
change these values, the form object will not get the new values until
you
hit submit.    Having the javascript function call submit is not an
option
either...   Any ideas on how best to do this??

If I could access my form-bean directly within the Javascript method,
that
would be an option to (as I could call the set method on the form
object)
but I am not sure if the javascript can access the form object directly
and
call a set method?

thanks,
Theron


--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to