Does it mean, we need to have a form element, probably an HTML:hidden
With name "addNewMode" to specify if we're adding or modifying?

Rgds.
Patrick.

-----Original Message-----
From: Brian Barnett [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 09, 2004 8:16 AM
To: Struts Users Mailing List
Subject: RE: Three JSPs in one


I've used the JSP core tags, <c:choose>, to do this. The snippet below
just shows how I determine if I'm adding or not. If adding, I display
the add title, otherwise the edit title. You could add another <c:when>
for view only.

<c:choose>
  <c:when test="${myFormBean.isAddNewMode()}">
    <td>
      <fmt:message key=" myFormBean.newTitle" bundle="${loc}"/>
    </td>
  </c:when>
  <c:otherwise>
    <td>
      <fmt:message key=" myFormBean.editTitle" bundle="${loc}"/>
    </td>
  </c:otherwise>
</c:choose>

You should be able to use the same code in your JSP for both the add and
the edit (unless there are fields that are mutually exclusive to the add
or the edit), but you'll have to use <c:choose> tags to separate the
add/edit code from the view code.

<c:choose>
  <c:when test="${myFormBean.isViewMode()}">
    -- code that displays the view only page --
  </c:when>
  <c:otherwise>
    -- code that displays the add/edit page --
  </c:otherwise>
</c:choose>


Brian Barnett

-----Original Message-----
From: Ciaran Hanley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 08, 2004 4:28 PM
To: Struts User Mailing List
Subject: Three JSPs in one

Hi 
 
In my application I am currently performing add user, view user and edit
user functions on separate JSPs.
 
So I have:         adduser.jsp to add users through a form
viewuser.jsp to view a users details in plain text
edituser.jsp to edit a users details in a populated form
 
Instead of having three different pages I would like to perform these
functions all on one page, the thing is I don't want to use any
scriptlets on my page. Is there away of using the html-logic tags to
test for which task I would like to perform, or some other method I can
use to do this, I cant figure it out.
 
Basically something that will do
 
If(select view)
{
      show details on page
}
else If(select edit)
{
      show users details in a form for update
}
else
{
      show form on page to add user
}
 
I was thinking some sort of logic
 
<logic:present (view)>
  ..view details
</logic:present>
 
<logic:present (add)>
  ..view details
</logic:present>
 
<logic:present (edit)>
  ..view details
</logic:present>
 
Anybody done this before?
 
 
Many Thanks
Ciaran

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


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

Reply via email to