You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Preston CRAWFORD <Pr...@state.or.us> on 2005/11/18 04:22:46 UTC

How would you solve this problem?

Okay, this is a little complex, so hopefully I can describe it well so
as not to confuse anyone. 

We have a need for the following. We need a reusable set of actions,
JSPs, etc. that operate in a popup to allow the user to search for a
medical provider. That's easy enough. The catch is this. The reason for
a popup is because the UI requirement is that the user perform the
search and then (as transparent as possible to them) have the page
refresh the portions of the display that say what medical provider is
currently selected. So you might have a page. In other words when the
search is performed a hidden form field will get updated (via Javascript
currently) with selected Provider ID. And then N number of fields are
going to be populated with some data to let the user know which provider
has been selected.

The trick is that since we're using Javascript currently the Javascript
is basically statically calling form names and form fields and changing
data based on what it's getting from the search action. So something
like this.

<script type="text/javascript" language="JavaScript">
<!--
    function callOnloadFunctions() {
        updateParentAndCloseSelf();
    }
             
    function updateParentAndCloseSelf() {
        changeParentFormValue('medicalInfoForm', 'hospital', '<c:out
value="${chosenProvider}" />');
        changeParentDOMElement('hospitalLabel', '<c:out
value="${chosenProvider}" />');
        window.close();
    }
//-->
</script>

Obviously problem #1 is that this JSP page can't be used on other views
because it references by name the name of the form. I'm not sure how to
dynamically get this to the JSP page without passing around a token of
some kind or passing around values in the request stream. That seems
like it could get ugly. Plus if I have to update, visually, more than
just the name of the hospital, for example, how would I handle that?
Imagining ANOTHER JSP page with separate Javascript.

    function updateParentAndCloseSelf() {
        changeParentFormValue('anotherForm', 'hospital', '<c:out
value="${chosenProvider}" />');
        changeParentDOMElement('hospitalLabel', '<c:out
value="${chosenProvider}" />');
        changeParentDOMElement('hospitalAddressLabel', '<c:out
value="${chosenProvider}" />');
        changeParentDOMElement('hospitalStateLabel', '<c:out
value="${chosenProvider}" />');
        window.close();
    }

In short, it could get REALLY ugly. 

Now another option is that we actually give in (I say give in because
it would mean a page refresh, something that might not go over well),
submit the form, but don't save the data to the database yet, and then
somehow via request or session retain any other field data they may have
changed for when we hit the page again, without saving it to the
database.

Okay, hopefully that makes some sense.

Basically we want a popup that performs a search, updates some data on
the page and in the form on the page, without actually doing the final
submit and save. And we'd like it to be reusable, if possible. So far we
can't think of the best way to approach this, in terms of the UI.
Hopefully someone gets the question and can help. If not I understand,
believe me. 

Preston

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


Re: How would you solve this problem?

Posted by R Raghavan <rr...@novell.com>.
hi,
 you can try some technique similar to AJAX. Open the popup and do the
necessary search either directly doing a http request..with submit or
using HttpXMLRequest if your server support such request. And then use
javascript window.open.href etc to point to the form in the page and do
the necessary updations.you can both change the form values or add
components to the html page.
try it..do inform the result.
Regards,
R.Raghavan
 
>>> jmikus@gmail.com 11/18/05 1:23 pm >>> 
On 11/17/05, Preston CRAWFORD <Pr...@state.or.us> wrote:
> the UI requirement is that the user perform the
> search and then (as transparent as possible to them) have the page
> refresh the portions of the display that say what medical provider
is
> currently selected.

Ajax?

> Basically we want a popup that performs a search, updates some data
on
> the page and in the form on the page, without actually doing the
final
> submit and save.

You can submit HTML form to server, store temporary data in the
session (for example, as a nested property of session- scoped
ActionForm) and then commit session data to the database only if
needed. If not needed, session data is discarded and database knows
nothing about it.

> Hopefully someone gets the question and can help.

I guess I did not :)

Michael.

---------------------------------------------------------------------
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: How would you solve this problem?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 11/17/05, Preston CRAWFORD <Pr...@state.or.us> wrote:
> the UI requirement is that the user perform the
> search and then (as transparent as possible to them) have the page
> refresh the portions of the display that say what medical provider is
> currently selected.

Ajax?

> Basically we want a popup that performs a search, updates some data on
> the page and in the form on the page, without actually doing the final
> submit and save.

You can submit HTML form to server, store temporary data in the
session (for example, as a nested property of session-scoped
ActionForm) and then commit session data to the database only if
needed. If not needed, session data is discarded and database knows
nothing about it.

> Hopefully someone gets the question and can help.

I guess I did not :)

Michael.

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


Re: How would you solve this problem?

Posted by Hubert Rabago <hr...@gmail.com>.
Sorry for coming in late to the discussion but I only read this thread now.

I may have misunderstood the problem.  I'm thinking the popup will
display a list of providers matching the search parameters, and the
user can select any of them by checking one, and the fields on the
form on the parent window displays the values for the checked
provider.  And when the user selects another provider from the
results, the form updates itself on the parent window.  Did I get it? 
Well, if I'm close anyway, maybe what I'm thinking will work.

I would solve this problem by having the popup concentrate on
searching for a provider, and leave the problem of populating form
fields to the calling (parent) window.

The popup would have a reference to the parent, so I can call a JS
function on the parent.  With JS, even the function to call can be
dynamic, so it could be a parameter that the parent window sends to
the popup ("call my 'showProvider' method when the user selects a
provider").  The parameter to the "showProvider" method would be the
provider ID.

When showProvider is called, it would send an XMLHttpRequest to
retrieve the details of said provider.  I'd have a method which I can
call with the XML result of the call, as well as the form name or form
variable, and will begin to populate the fields that it finds.  With a
decent naming convention, I can write this method so that I can reuse
it whereever I have this form.

The reusable portions would be the popup (completely parameterized),
the XMLHttpRequest handling, the form population function, even the
method that gets called when a provider is selected.  The form names
would have to match across all the pages using it.

Hope this helps.  Let me know if you want me to clarify any point. 
Sorry if I misunderstood your problem and offered a bogus solution.

Hubert


On 11/17/05, Preston CRAWFORD <Pr...@state.or.us> wrote:
> Okay, this is a little complex, so hopefully I can describe it well so
> as not to confuse anyone.
>
> We have a need for the following. We need a reusable set of actions,
> JSPs, etc. that operate in a popup to allow the user to search for a
> medical provider. That's easy enough. The catch is this. The reason for
> a popup is because the UI requirement is that the user perform the
> search and then (as transparent as possible to them) have the page
> refresh the portions of the display that say what medical provider is
> currently selected. So you might have a page. In other words when the
> search is performed a hidden form field will get updated (via Javascript
> currently) with selected Provider ID. And then N number of fields are
> going to be populated with some data to let the user know which provider
> has been selected.
>
> The trick is that since we're using Javascript currently the Javascript
> is basically statically calling form names and form fields and changing
> data based on what it's getting from the search action. So something
> like this.
>
> <script type="text/javascript" language="JavaScript">
> <!--
>    function callOnloadFunctions() {
>        updateParentAndCloseSelf();
>    }
>
>    function updateParentAndCloseSelf() {
>        changeParentFormValue('medicalInfoForm', 'hospital', '<c:out
> value="${chosenProvider}" />');
>        changeParentDOMElement('hospitalLabel', '<c:out
> value="${chosenProvider}" />');
>        window.close();
>    }
> //-->
> </script>
>
> Obviously problem #1 is that this JSP page can't be used on other views
> because it references by name the name of the form. I'm not sure how to
> dynamically get this to the JSP page without passing around a token of
> some kind or passing around values in the request stream. That seems
> like it could get ugly. Plus if I have to update, visually, more than
> just the name of the hospital, for example, how would I handle that?
> Imagining ANOTHER JSP page with separate Javascript.
>
>    function updateParentAndCloseSelf() {
>        changeParentFormValue('anotherForm', 'hospital', '<c:out
> value="${chosenProvider}" />');
>        changeParentDOMElement('hospitalLabel', '<c:out
> value="${chosenProvider}" />');
>        changeParentDOMElement('hospitalAddressLabel', '<c:out
> value="${chosenProvider}" />');
>        changeParentDOMElement('hospitalStateLabel', '<c:out
> value="${chosenProvider}" />');
>        window.close();
>    }
>
> In short, it could get REALLY ugly.
>
> Now another option is that we actually give in (I say give in because
> it would mean a page refresh, something that might not go over well),
> submit the form, but don't save the data to the database yet, and then
> somehow via request or session retain any other field data they may have
> changed for when we hit the page again, without saving it to the
> database.
>
> Okay, hopefully that makes some sense.
>
> Basically we want a popup that performs a search, updates some data on
> the page and in the form on the page, without actually doing the final
> submit and save. And we'd like it to be reusable, if possible. So far we
> can't think of the best way to approach this, in terms of the UI.
> Hopefully someone gets the question and can help. If not I understand,
> believe me.
>
> Preston

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