Looks neat, but I'd rather have two lines of kludgy code than have to add
two additional libraries to the application. It's pretty basic so far, so
it's probably not worth adding that layer of complexity for this one thing.
Seems like I ought to be able to do this:

<app:HasLogin idMember="<%=loginForm.get("fkMember")%>">
dfdfdf
</app:HasLogin>

but it claims not to know what loginForm is.  Argh.

----- Original Message -----
From: "Dan Tran" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 12, 2003 9:17 PM
Subject: Re: Accessing DynaActionForm fields within custom tag


> Use the combination of JSTL and Struts-el
>
> Here is an example, where based on a property in my form, the submit
button
> is displayed differently.  The formName is defined in your struts config
> file
>
> Good luck
>
> -Dan
>
> <%@ page contentType="text/html; charset=utf-8" %>
>
> <%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
>
> <%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
>
> <%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %>
>
> <%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
>
> <html-el:html locale="true">
>
> <head>
>
> <title>Student</title>
>
> <META HTTP-EQUIV="Expires" CONTENT="-1">
>
> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
>
> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
>
> <LINK REL=STYLESHEET HREF="../site.css" TYPE="text/css">
>
> <html-el:base />
>
> </head>
>
>
>
> <body class=mainframe>
>
> <center>
>
> <html-el:errors />
>
> <c:set value="${loginUserForm.map.command}" var="command"/>
>
>
>
> <html-el:form focus="userName" action="/dispatch" >
>
> <table border="0" align="center" >
>
> <html-el:hidden property="command"/>
>
> <tr>
>
> <td align="left">
>
> <bean-el:message key="label.userName" />
>
> </td>
>
> <td align="left">
>
> <html-el:text property="userName />
>
> </td>
>
> </tr>
>
>
>
> <tr>
>
> <td align="left">
>
> <bean-el:message key="label.password" />
>
> </td>
>
> <td align="left">
>
> <html-el:password property="password" readonly="${istrue}" />
>
> </td>
>
> </tr>
>
> <tr>
>
> <td align="left"/>
>
> <td align="left">
>
> <c:choose >
>
> <c:when test="${command == 'add'}">
>
> <html-el:submit property="action">
>
> <bean-el:message key="button.user.add"/>
>
> </html-el:submit>
>
> </c:when>
>
> <c:when test="${command == 'update'}">
>
> <html-el:submit property="action">
>
> <bean-el:message key="button.user.update"/>
>
> </html-el:submit>
>
> </c:when>
>
> <c:when test="${command == 'delete'}">
>
> <html-el:submit property="action">
>
> <bean-el:message key="button.user.delete"/>
>
> </html-el:submit>
>
> </c:when>
>
> </c:choose>
>
> </td>
>
> </tr>
>
> </table>
>
> </html-el:form>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: "Ian Hunter" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Wednesday, March 12, 2003 5:51 PM
> Subject: Accessing DynaActionForm fields within custom tag
>
>
> > I have a form where the submit button is supposed to say "add login" or
> > "update login" depending on if the user in question (based on field
> > fkMember) already exists in the login database.  I have tags called
> HasLogin
> > and HasNoLogin that take an integer parameter, and return whether or not
> the
> > condition is true.
> >
> > I am using a DynaActionForm to populate the rest of the fields.  The
> > DynaActionForm is a session scoped bean called "loginForm" -- the
> following
> > code actually works:
> >
> > <!-- form tags and all that above -->
> > <td><html:submit>
> > <jsp:useBean id="loginForm" scope="session"
> > class="org.apache.struts.action.DynaActionForm"/>
> > <app:HasNoLogin idMember="<%=new Integer
> > (Integer.parseInt((String)loginForm.get("fkMember")))%>">
> > <bean:message key="button.addlogin"/>
> > </app:HasNoLogin>
> > <app:HasLogin idMember="<%=new Integer
> > (Integer.parseInt((String)loginForm.get("fkMember")))%>">
> > <bean:message key="button.updatelogin"/>
> > </app:HasLogin>
> > </html:submit></td>
> > <!-- rest of page below -->
> >
> > The syntax above offends my sensibilities.  First, I ought to be able to
> > refer to the bean in question without using a <jsp:useBean> I think;
it's
> > obviously available to the rest of the form, if the form works (and it
> > does).  Seconds, casting the get() as a String and doing a parseInt to
it
> to
> > create a new Integer is silly.
> >
> > Isn't there a more elegant way to do this?
> >
> > Ian
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>


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

Reply via email to