You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/10/03 23:16:11 UTC

Need some design hand-holding

Okay, I [finally] have a simple form working-- there's an editContact
action, the target of the form is /saveContact and if all goes well you end
up on confirmContact.jsp.  The DAO layer is working nicely.

*BUT* (of course...) the form needs to be much more complex, and I need help
figuring out how to do this.

First, one of the fields on the form needs a database lookup.  When you
first see the form, it's a text area.  If you put in a name and click the
button to the right, it should go off and present a list of matching names.
You pick one, and then you're back at the original form.  Only now there's
no text area, but instead you see the full name of the person you chose, and
a 'delete' button out to the right.  And it has to remember all of the other
choices, of course.

So I think I might need the logic tags, and either show the text area *or*
the read-only information, depending on whether there is a value or not.

I think I can get it to go off to the resolution screen... can the
<forward name="nameResolution"         path="??????"/>
tag have another action instead of a .jsp file?  How do I get *back* where I
came from?  Here's where I get totally lost.

About those "buttons" out to the right of the text area:  I'm planning on
having multiple submit buttons, but stop me if that's going to be a problem

Thanks in advance for any guidance you can offer.  I have this working in a
procedural language, but I'm having trouble converting it over to Java and
Struts.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Re: Need some design hand-holding

Posted by "Peter S. Hamlen" <ph...@mail.com>.
Wendy,

A possible way to do all of this - not necessarily the best, but enough
to get you started.

Assume:
1)  Let's assume that the field that takes the name is called
"ContactName" in your form.
2)  The button next to "Contact Name" has a value of "NameLookup", and
is a submit button (as opposed to hyperlink, etc.)
3)  Your form should be saved in "session scope"

Possible Solution:

1)  Have your editContact action look at which submit button got
pressed, and if "NameLookup" has been pressed, then return a "forward"
to the NameLookup Action

2)  The NameLookup Action looks up the value of ContactName in the form
that's stored in the Session.  It then executes the search, stores the
search results in the request, and then forwards to "nameLookup.jsp"

3)  "nameLookup.jsp" displays the results of the search page, and a form
that points to a "chooseName" action.  

4)  When the user submits from the nameLookup.jsp page, the ChooseName
action sets the name field of the editContact form, and also sets the
"nameChosen" flag in the editContact form.  It then forwards back to the
"editContact.jsp" page.

5)  The "editContact.jsp" page uses a <logic:present> tag and a
<logic:notpresent> tag to see if "nameChosen" has been set.  If it has,
it just displays the name and an "edit" button.  If it hasn't, it
displays a text box and a "choose" button.

Possible improvements:
1)  You might be able to eliminate the "ChooseName" action if you set
your form fields correctly.  That is, the nameLookup.jsp page submits to
the same action as "editContact.jsp" (because they are actually both
"editing" the contact.


HTH
-Peter

On Thu, 2002-10-03 at 17:16, Wendy Smoak wrote:
> 
> Okay, I [finally] have a simple form working-- there's an editContact
> action, the target of the form is /saveContact and if all goes well you end
> up on confirmContact.jsp.  The DAO layer is working nicely.
> 
> *BUT* (of course...) the form needs to be much more complex, and I need help
> figuring out how to do this.
> 
> First, one of the fields on the form needs a database lookup.  When you
> first see the form, it's a text area.  If you put in a name and click the
> button to the right, it should go off and present a list of matching names.
> You pick one, and then you're back at the original form.  Only now there's
> no text area, but instead you see the full name of the person you chose, and
> a 'delete' button out to the right.  And it has to remember all of the other
> choices, of course.
> 
> So I think I might need the logic tags, and either show the text area *or*
> the read-only information, depending on whether there is a value or not.
> 
> I think I can get it to go off to the resolution screen... can the
> <forward name="nameResolution"         path="??????"/>
> tag have another action instead of a .jsp file?  How do I get *back* where I
> came from?  Here's where I get totally lost.
> 
> About those "buttons" out to the right of the text area:  I'm planning on
> having multiple submit buttons, but stop me if that's going to be a problem
> 
> Thanks in advance for any guidance you can offer.  I have this working in a
> procedural language, but I'm having trouble converting it over to Java and
> Struts.
> 
> -- 
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>