You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Karl <ka...@webartjapan.com> on 2003/03/04 09:51:53 UTC

Struts not parsing HTML correctly?

There are actually 2 problems I'm experiencing:

Firstly, I have the following snippet in one of my forms (user_add.jsp):

                    <!-- tr>
                        <th>Contract User</th>
                        <td>
                            <html:checkbox property="contractUser"/>
                        </td>
                    </tr -->

If this is present, struts fails with the following error:

org.apache.jasper.JasperException: No getter method for property contractUser 
of bean org.apache.struts.taglib.html.BEAN

This happens whether that section is commented out or not, but does not occur 
if I remove the code entirely.


The second problem is that I actually DO have a getter (and setter) method for 
contractUser in UserForm.java:

    /* Contract User */
    private boolean contractUser = false;
    public boolean getContractUser() {
        return this.contractUser;
    }
    public void setContractUser(boolean contractUser) {
        this.contractUser = contractUser;
    }


I have the following in my struts config:

<struts-config>
    <form-beans>
...
        <form-bean name="userForm"
                   type="com.somewhere.aproject.UserForm" />
...
    </form-beans>
    <action-mappings>
...
        <action path="/screen_user_add"
             forward="/user_add.jsp"
                name="userForm"
            validate="false"/>
...
    </action-mappings>
</struts-config>


I know the configuration is right since the rest of the fields work fine.  
Should I be using type String instead of boolean for contractUser?


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


Re: Struts not parsing HTML correctly?

Posted by Karl <ka...@webartjapan.com>.
Oh almost forgot: it's struts 1.0.2 running under Tomcat 4.1

2003 3月 4 火曜日 17:51、Karl さんは書きました:
> There are actually 2 problems I'm experiencing:
>
> Firstly, I have the following snippet in one of my forms (user_add.jsp):
>
>                     <!-- tr>
>                         <th>Contract User</th>
>                         <td>
>                             <html:checkbox property="contractUser"/>
>                         </td>
>                     </tr -->
>
> If this is present, struts fails with the following error:
>
> org.apache.jasper.JasperException: No getter method for property
> contractUser of bean org.apache.struts.taglib.html.BEAN
>
> This happens whether that section is commented out or not, but does not
> occur if I remove the code entirely.
>
>
> The second problem is that I actually DO have a getter (and setter) method
> for contractUser in UserForm.java:
>
>     /* Contract User */
>     private boolean contractUser = false;
>     public boolean getContractUser() {
>         return this.contractUser;
>     }
>     public void setContractUser(boolean contractUser) {
>         this.contractUser = contractUser;
>     }
>
>
> I have the following in my struts config:
>
> <struts-config>
>     <form-beans>
> ...
>         <form-bean name="userForm"
>                    type="com.somewhere.aproject.UserForm" />
> ...
>     </form-beans>
>     <action-mappings>
> ...
>         <action path="/screen_user_add"
>              forward="/user_add.jsp"
>                 name="userForm"
>             validate="false"/>
> ...
>     </action-mappings>
> </struts-config>
>
>
> I know the configuration is right since the rest of the fields work fine.
> Should I be using type String instead of boolean for contractUser?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: Struts not parsing HTML correctly?

Posted by Karl <ka...@webartjapan.com>.
Actually, once I explicitly specified what form to use within the jsp page 
(using the name and type attributes of the html:form tag), it worked fine, 
but it seems weird to have to specify what form to use both in the jsp page 
and in struts-config.xml.


2003 3月 5 水曜日 11:23、Dave Newton さんは書きました:
> On Tue, 2003-03-04 at 20:20, Karl wrote:
> >         <action path="/screen_user_add"
> >              forward="/user_add.jsp"
> >                 name="userForm"
> >             validate="false"/>
>
> My impression was that if you used the "forward" attribute that the
> Action class would not be instantiated and called, instead that it would
> forward directly to the JSP page.
>
> Does the error occur if you use "input" instead of "forward"?
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: Struts not parsing HTML correctly?

Posted by Dave Newton <da...@solaraccess.com>.
On Tue, 2003-03-04 at 20:20, Karl wrote:
>         <action path="/screen_user_add"
>              forward="/user_add.jsp"
>                 name="userForm"
>             validate="false"/>

My impression was that if you used the "forward" attribute that the
Action class would not be instantiated and called, instead that it would
forward directly to the JSP page.

Does the error occur if you use "input" instead of "forward"?

Dave



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


RE: Problems with the iterate tag

Posted by James Mitchell <jm...@apache.org>.
Why are you specifying property="data"?

>  <bean:write name="element" property="data"/>.<br/>
                              ^^^^^^^^^^^^^^^

Try removing that.

--
James Mitchell
Web Developer/Struts Evangelist
http://jakarta.apache.org/struts/

"People demand freedom of speech to make up for the freedom of thought
which they avoid."
    - Soren Aabye Kierkegaard (1813-1855)




> -----Original Message-----
> From: Karl [mailto:karl@webartjapan.com] 
> Sent: Tuesday, March 04, 2003 11:16 PM
> To: Struts Users Mailing List
> Subject: Problems with the iterate tag
> 
> 
> I'm trying to get my jsp page to iterate over a collection of 
> objects, 
> printing one object property (data) on every line.
> 
> I've tried implementing the following:
> 
> test.jsp:
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> 
> <html:html>
>     <head>
>         <title>Test</title>
>     </head>
>     <body>
>         <logic:iterate id="element" name="testContainer" 
> property="testData">
>             <bean:write name="element" property="data"/>.<br/>
>         </logic:iterate>
>         END<br/>
>     </body>
> </html:html>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> TestForm.java:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> package com.somewhere;
> 
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.*;
> import java.util.*;
> 
> public final class TestForm extends ActionForm {
> 
>     private Collection myCollection;
> 
>     {
>         myCollection = new Vector();
>         myCollection.add(new TestData("1"));
>         myCollection.add(new TestData("two"));
>         myCollection.add(new TestData("III"));
>     }
> 
>     public Collection getTestData() {
>         return myCollection;
>     }
> }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> TestData.java:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> package com.somewhere;
> 
> public final class TestData {
> 
>     private String myData;
> 
>     public TestData(String value) {
>         myData = value;
>     }
> 
>     public String getData() {
>         return myData;
>     }
> }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> struts-config.xml:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> <struts-config>
>     <form-beans type="org.apache.struts.action.ActionFormBean">
>         <form-bean name="testContainer" 
> type="com.somewhere.TestForm" />
>     </form-beans>
>     <action-mappings type="org.apache.struts.action.ActionMapping">
>         <action path="/do_test" forward="/test.jsp" 
> name="testContainer" 
> validate="false"/>
>     </action-mappings>
> </struts-config>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> However, when I try to run this, it fails:
> 
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> org.apache.jasper.JasperException: No getter method for 
> property data of bean 
> element
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> It must be something with either "element" being the id of 
> the iteration or 
> the name of the write tag, but I can't see any other way that 
> I'd tell it to 
> access the correct data.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


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


Problems with the iterate tag

Posted by Karl <ka...@webartjapan.com>.
I'm trying to get my jsp page to iterate over a collection of objects, 
printing one object property (data) on every line.

I've tried implementing the following:

test.jsp:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <logic:iterate id="element" name="testContainer" property="testData">
            <bean:write name="element" property="data"/>.<br/>
        </logic:iterate>
        END<br/>
    </body>
</html:html>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


TestForm.java:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
package com.somewhere;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import java.util.*;

public final class TestForm extends ActionForm {

    private Collection myCollection;

    {
        myCollection = new Vector();
        myCollection.add(new TestData("1"));
        myCollection.add(new TestData("two"));
        myCollection.add(new TestData("III"));
    }

    public Collection getTestData() {
        return myCollection;
    }
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


TestData.java:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
package com.somewhere;

public final class TestData {

    private String myData;

    public TestData(String value) {
        myData = value;
    }

    public String getData() {
        return myData;
    }
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


struts-config.xml:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<struts-config>
    <form-beans type="org.apache.struts.action.ActionFormBean">
        <form-bean name="testContainer" type="com.somewhere.TestForm" />
    </form-beans>
    <action-mappings type="org.apache.struts.action.ActionMapping">
        <action path="/do_test" forward="/test.jsp" name="testContainer" 
validate="false"/>
    </action-mappings>
</struts-config>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


However, when I try to run this, it fails:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
org.apache.jasper.JasperException: No getter method for property data of bean 
element
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


It must be something with either "element" being the id of the iteration or 
the name of the write tag, but I can't see any other way that I'd tell it to 
access the correct data.


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


Re: Design issue: forms and iterations on the same page

Posted by alexj <al...@freesurf.ch>.
I made a little mistake in my code but it's not really important for you ;))
...
  form.setName(student.getName ());




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


Re: Design issue: forms and iterations on the same page

Posted by alexj <al...@freesurf.ch>.
You may have a look to the display tag lib who provide an
really easy to use purpose for your use case.

I show you an sample code I use in my view I got :

<%@ page session="true" %>
<%@ page import="org.apache.taglibs.display.test.TestList,
                 org.apache.taglibs.display.test.ListHolder,
                 java.util.List"%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/display" prefix="display"
%>
<%@ taglib uri="/WEB-INF/struts-menu.tld" prefix="menu"%>

<html>
    <head>
    </head>

<body>
  <script language="JavaScript1.2" src="./scripts/coolmenus3.js">
  </script>
  <script src="./scripts/coolmenu-config.js">
</script>

<menu:useMenuDisplayer name="CoolMenu"
bundle="org.apache.struts.action.MESSAGE">
    <menu:displayMenu name="ToDoListMenuFile"/>
    <menu:displayMenu name="ToDoListMenuEdit"/>
    <menu:displayMenu name="CaseDetailMenuCase"/>
</menu:useMenuDisplayer>
<p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<display:table width="85%"align="left"
              name="students"
              scope="session"
              pagesize="5"
              requestURI="/ibmss/form/viewstudent.jsp"
              export="true"
              decorator="org.apache.taglibs.display.test.Wrapper">

  <display:column property="idPersonne"
                  title="ID"
                  href="/ibmss/getstudent.do"
                  paramId="idPersonne"
                  paramProperty="idPersonne"  />
  <display:column property="name" title="Nom"/>
  <display:column property="firstName" title="Prenom"/>
  <display:column property="adress" title="Adresse"/>
  <display:column property="city" title="Ville"/>
  <display:column property="npa" title="Npa"/>
  <display:column property="phoneNumber" title="Telephone"/>
  <display:column property="email" title="Email" autolink="true"/>
  <display:column property="insuranceName" title="Assurance"/>
  <display:column property="insuranceNumber" title="No assure"/>
  <display:column property="formationSelected" title="Formation"/>
  <display:column property="group" title="Groupe"/>
</display:table>

</body>
</html>

My getstudent action :

// Created by Xslt generator for Eclipse.

// XSL : not found (java.io.FileNotFoundException: (Le chemin d'acces
specifie est introuvable))

// Default XSL used : easystruts.jar$org.easystruts.xslgen.JavaClass.xsl

package soft.ibmss.struts.action;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import soft.ibmss.struts.form.StudentForm;

import org.apache.struts.Globals;

public class GetstudentAction extends Action {

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {


try {

form = buildStudent(request.getParameter("idPersonne"));

if (form == null) {

System.out.println ("form nulle");

}

if ("request".equals(mapping.getScope() )) {

request.setAttribute(mapping.getAttribute(), form);

}

else {

HttpSession session = request.getSession();

session.setAttribute(mapping.getAttribute(), form);

}

}

catch (Exception ex) {

System.out.println(ex.getMessage());

}

return mapping.findForward("success");

}

public ActionForm buildStudent (String name) throws Exception {


Student student = Student.getStudent (name);

form = new StudentForm ();

form.setIdPersonne (student.getName ());

form.setIdPersonne(student.getIdPerson ());

form.setName(rs.getString ("nom"));

........

return form;


}



I added in my struts-config :



<action

attribute="studentForm"

name="studentForm"

path="/getstudent"

scope="request"

type="soft.ibmss.struts.action.GetstudentAction"

validate="false">

<set-property property="secure" value="false" />

<forward name="success" path="/form/editstudent.jsp" />

</action>

Then I define an editstudent action to retrieve the updated data from

the editstudent view page.

--

Alexandre Jaquet

----- Original Message -----
From: "Karl" <ka...@webartjapan.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 05, 2003 3:43 AM
Subject: Re: Design issue: forms and iterations on the same page


Oops, just realized I used my mock-up page.  The part showing the list of
administrators will of course use an iterate tag =)


2003 3月 5 水曜日 11:39、Karl さんは書きました:
> I'm trying to figure out a good design strategy for building a page that
> allows viewing, adding, editing, and deleting of administrators.
>
> At the top of the page I have the form itself:
>
>             <html:form action="screen_manage_administrators.do"
> name="AdministratorUserForm"
> type="com.somewhere.aproject.AdministratorUserForm">
>                 <table>
>                     <tr>
>                         <th>Name</th>
>                         <td>
>                             <html:text property="userName"  maxlength="16"
> size="16"/>
>                         </td>
>                     </tr>
>                     <tr>
>                         <th>Password</th>
>                         <td>
>                             <html:password property="password"
> maxlength="8" size="8"/>
>                         </td>
>                     </tr>
>                     <tr>
>                         <td>
>                             <html:submit value="Set"/>
>                         </td>
>                     </tr>
>                 </table>
>             </html:form>
>
> Under that I want a list of existing administrators (there will probabl
> only be 5-10 admins, and definitely not more than 20):
>
>             <table>
>                 <tr>
>                     <th>Name</th>
>                 </tr>
>                 <tr>
>                     <td>
>                         me
>                     </td>
>                     <td>
>                         <html:link
> href="screen_manage_administrators.do?num=0">Edit</html:link>&nbsp;
>                         <html:link
> href="do_administrator_remove.do?num=0">Delete</html:link>
>                     </td>
>                 </tr>
>                 <tr>
>                     <td>
>                         myself
>                     </td>
>                     <td>
>                         <html:link
> href="screen_manage_administrators.do?num=1">Edit</html:link>&nbsp;
>                         <html:link
> href="do_administrator_remove.do?num=1">Delete</html:link>
>                     </td>
>                 </tr>
>             </table>
>
>
> If you enter in data that does not match an existing administrator name
and
> submit it, it adds the administrator.
> If you click on the "edit" link of one of the administrators, it puts that
> admin's details into the edit form.
> If the administrator name matches an existing name, the data is updated.
> If you click on delete, it will ask confirmation and then delete the
entry.
>
>
> My first question is:  Is it a good idea to be placing all of this
> functionality in one page, or should I be spreading it to other pages?
>
> My second question is: How would I implement such a layout in struts?
> I can associate a UserForm object with the form, but how would I interpret
> which administrator data to load into the edit form (via the argument
> "num")? Should I be making a separate form object to provide the list of
> administrators and then iterate over that list?  If so, how do I access 2
> different ActionForms within the same page?
> Would I be better off making an ActionForm that contains all of the data
> for the edit form as well as the collection of administrator data?
>
>
> Cheers!
>
> Karl
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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



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


Re: Design issue: forms and iterations on the same page

Posted by Karl <ka...@webartjapan.com>.
Oops, just realized I used my mock-up page.  The part showing the list of 
administrators will of course use an iterate tag =)


2003 3月 5 水曜日 11:39、Karl さんは書きました:
> I'm trying to figure out a good design strategy for building a page that
> allows viewing, adding, editing, and deleting of administrators.
>
> At the top of the page I have the form itself:
>
>             <html:form action="screen_manage_administrators.do"
> name="AdministratorUserForm"
> type="com.somewhere.aproject.AdministratorUserForm">
>                 <table>
>                     <tr>
>                         <th>Name</th>
>                         <td>
>                             <html:text property="userName"  maxlength="16"
> size="16"/>
>                         </td>
>                     </tr>
>                     <tr>
>                         <th>Password</th>
>                         <td>
>                             <html:password property="password" 
> maxlength="8" size="8"/>
>                         </td>
>                     </tr>
>                     <tr>
>                         <td>
>                             <html:submit value="Set"/>
>                         </td>
>                     </tr>
>                 </table>
>             </html:form>
>
> Under that I want a list of existing administrators (there will probabl
> only be 5-10 admins, and definitely not more than 20):
>
>             <table>
>                 <tr>
>                     <th>Name</th>
>                 </tr>
>                 <tr>
>                     <td>
>                         me
>                     </td>
>                     <td>
>                         <html:link
> href="screen_manage_administrators.do?num=0">Edit</html:link>&nbsp;
>                         <html:link
> href="do_administrator_remove.do?num=0">Delete</html:link>
>                     </td>
>                 </tr>
>                 <tr>
>                     <td>
>                         myself
>                     </td>
>                     <td>
>                         <html:link
> href="screen_manage_administrators.do?num=1">Edit</html:link>&nbsp;
>                         <html:link
> href="do_administrator_remove.do?num=1">Delete</html:link>
>                     </td>
>                 </tr>
>             </table>
>
>
> If you enter in data that does not match an existing administrator name and
> submit it, it adds the administrator.
> If you click on the "edit" link of one of the administrators, it puts that
> admin's details into the edit form.
> If the administrator name matches an existing name, the data is updated.
> If you click on delete, it will ask confirmation and then delete the entry.
>
>
> My first question is:  Is it a good idea to be placing all of this
> functionality in one page, or should I be spreading it to other pages?
>
> My second question is: How would I implement such a layout in struts?
> I can associate a UserForm object with the form, but how would I interpret
> which administrator data to load into the edit form (via the argument
> "num")? Should I be making a separate form object to provide the list of
> administrators and then iterate over that list?  If so, how do I access 2
> different ActionForms within the same page?
> Would I be better off making an ActionForm that contains all of the data
> for the edit form as well as the collection of administrator data?
>
>
> Cheers!
>
> Karl
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Design issue: forms and iterations on the same page

Posted by Karl <ka...@webartjapan.com>.
I'm trying to figure out a good design strategy for building a page that 
allows viewing, adding, editing, and deleting of administrators.

At the top of the page I have the form itself:

            <html:form action="screen_manage_administrators.do" 
name="AdministratorUserForm" 
type="com.somewhere.aproject.AdministratorUserForm">
                <table>
                    <tr>
                        <th>Name</th>
                        <td>
                            <html:text property="userName"  maxlength="16" 
size="16"/>
                        </td>
                    </tr>
                    <tr>
                        <th>Password</th>
                        <td>
                            <html:password property="password"  maxlength="8" 
size="8"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <html:submit value="Set"/>
                        </td>
                    </tr>
                </table>
            </html:form>

Under that I want a list of existing administrators (there will probabl only 
be 5-10 admins, and definitely not more than 20):

            <table>
                <tr>
                    <th>Name</th>
                </tr>
                <tr>
                    <td>
                        me
                    </td>
                    <td>
                        <html:link 
href="screen_manage_administrators.do?num=0">Edit</html:link>&nbsp;
                        <html:link 
href="do_administrator_remove.do?num=0">Delete</html:link>
                    </td>
                </tr>
                <tr>
                    <td>
                        myself
                    </td>
                    <td>
                        <html:link 
href="screen_manage_administrators.do?num=1">Edit</html:link>&nbsp;
                        <html:link 
href="do_administrator_remove.do?num=1">Delete</html:link>
                    </td>
                </tr>
            </table>


If you enter in data that does not match an existing administrator name and 
submit it, it adds the administrator.
If you click on the "edit" link of one of the administrators, it puts that 
admin's details into the edit form.
If the administrator name matches an existing name, the data is updated.
If you click on delete, it will ask confirmation and then delete the entry.


My first question is:  Is it a good idea to be placing all of this 
functionality in one page, or should I be spreading it to other pages?

My second question is: How would I implement such a layout in struts?
I can associate a UserForm object with the form, but how would I interpret 
which administrator data to load into the edit form (via the argument "num")?
Should I be making a separate form object to provide the list of 
administrators and then iterate over that list?  If so, how do I access 2 
different ActionForms within the same page?
Would I be better off making an ActionForm that contains all of the data for 
the edit form as well as the collection of administrator data?


Cheers!

Karl


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


Re: Struts not parsing HTML correctly?

Posted by SP <pr...@comcast.net>.
Replace ur line with the below line. If does'nt work, copy ur code and
attach'em in e-mail.

<html:form action="screen_contract_edit.do"  name="userForm"
type="com.somewhere.aproject.UserForm" >



----- Original Message -----
From: "Karl" <ka...@webartjapan.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, March 04, 2003 8:37 PM
Subject: Re: Struts not parsing HTML correctly?


2003 3月 5 水曜日 10:28、SP さんは書きました:
> Hi
> Property "contractUser" must be boolean in UserForm.java
>
> Hope this helps.

I tried it with boolean before, but it didn't work, so someone on the list
said I should implement it as String... and it still doesn't work =(


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



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


Re: Struts not parsing HTML correctly?

Posted by Karl <ka...@webartjapan.com>.
2003 3月 5 水曜日 10:28、SP さんは書きました:
> Hi
> Property "contractUser" must be boolean in UserForm.java
>
> Hope this helps.

I tried it with boolean before, but it didn't work, so someone on the list 
said I should implement it as String... and it still doesn't work =(


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


Re: Struts not parsing HTML correctly?

Posted by SP <pr...@comcast.net>.
Hi
Property "contractUser" must be boolean in UserForm.java

Hope this helps.


----- Original Message -----
From: "Karl" <ka...@webartjapan.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, March 04, 2003 8:20 PM
Subject: Re: Struts not parsing HTML correctly?


2003 3月 4 火曜日 17:58、Nicolas De Loof さんは書きました:
>
> Yout <html:checkbox> is looking for a getter method for property
> contractUser (String getContractUser()) of the current formBean defined by
> a parent <html:form>.
>
> How are you using <html:fom> tag in your JSP ? Is the declared action path
> associated with the correct ActionFormBean in struts-config ?
>

I've implemented your recommendations but it's still complaining =(

I now have the following in user_add.jsp:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<html:html>
...
            <html:form action="screen_contract_edit.do">
...
                    <tr>
                        <th>Contract User</th>
                        <td>
                            <html:checkbox property="contractUser"/>
                        </td>
                    </tr>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And the following in UserForm.java:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
package com.somewhere.aproject;

...

public final class UserForm extends ActionForm {
...
    /* Contract User */
    private String contractUser = "false";
    public String getContractUser() {
        return this.contractUser;
    }
    public void setContractUser(String contractUser) {
        this.contractUser = contractUser;
    }
...
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And the following in struts-config.xml:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<struts-config>
    <form-beans>
...
        <form-bean name="userForm"
                   type="com.somewhere.aproject.UserForm" />
...
    </form-beans>
    <action-mappings>
...
        <action path="/screen_user_add"
             forward="/user_add.jsp"
                name="userForm"
            validate="false"/>
...
    </action-mappings>
</struts-config>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have other properties in the form as well.  The page works fine with the
rest of the properties (which are all text edit fields), but as soon as I
add
in this checkbox, it starts complaining:

when going to http://localhost:8080/aproject/screen_user_add.do

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
org.apache.jasper.JasperException: No getter method for property
contractUser
of bean org.apache.struts.taglib.html.BEAN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


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



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


Re: Struts not parsing HTML correctly?

Posted by Karl <ka...@webartjapan.com>.
2003 3月 4 火曜日 17:58、Nicolas De Loof さんは書きました:
>
> Yout <html:checkbox> is looking for a getter method for property
> contractUser (String getContractUser()) of the current formBean defined by
> a parent <html:form>.
>
> How are you using <html:fom> tag in your JSP ? Is the declared action path
> associated with the correct ActionFormBean in struts-config ?
>

I've implemented your recommendations but it's still complaining =(

I now have the following in user_add.jsp:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<html:html>
...
            <html:form action="screen_contract_edit.do">
...
                    <tr>
                        <th>Contract User</th>
                        <td>
                            <html:checkbox property="contractUser"/>
                        </td>
                    </tr>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And the following in UserForm.java:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
package com.somewhere.aproject;

...

public final class UserForm extends ActionForm {
...
    /* Contract User */
    private String contractUser = "false";
    public String getContractUser() {
        return this.contractUser;
    }
    public void setContractUser(String contractUser) {
        this.contractUser = contractUser;
    }
...
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And the following in struts-config.xml:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
<struts-config>
    <form-beans>
...
        <form-bean name="userForm"
                   type="com.somewhere.aproject.UserForm" />
...
    </form-beans>
    <action-mappings>
...
        <action path="/screen_user_add"
             forward="/user_add.jsp"
                name="userForm"
            validate="false"/>
...
    </action-mappings>
</struts-config>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have other properties in the form as well.  The page works fine with the 
rest of the properties (which are all text edit fields), but as soon as I add 
in this checkbox, it starts complaining:

when going to http://localhost:8080/aproject/screen_user_add.do

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
org.apache.jasper.JasperException: No getter method for property contractUser 
of bean org.apache.struts.taglib.html.BEAN
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


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


Re: Struts not parsing HTML correctly?

Posted by Nicolas De Loof <ni...@cgey.com>.
>
> Firstly, I have the following snippet in one of my forms (user_add.jsp):
>
>                     <!-- tr>
>                         <th>Contract User</th>
>                         <td>
>                             <html:checkbox property="contractUser"/>
>                         </td>
>                     </tr -->
>
> If this is present, struts fails with the following error:
>
> org.apache.jasper.JasperException: No getter method for property
contractUser
> of bean org.apache.struts.taglib.html.BEAN
>
> This happens whether that section is commented out or not, but does not
occur
> if I remove the code entirely.
>

As "<!-- -->" is HTML comment, it will not change the way jour JSP compiler
handles custom tags.


> The second problem is that I actually DO have a getter (and setter) method
for
> contractUser in UserForm.java

Yout <html:checkbox> is looking for a getter method for property
contractUser (String getContractUser()) of the current formBean defined by a
parent <html:form>.

How are you using <html:fom> tag in your JSP ? Is the declared action path
associated with the correct ActionFormBean in struts-config ?

Nico.



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


Re: Struts not parsing HTML correctly?

Posted by Karl <ka...@webartjapan.com>.
> >
> >                     <!-- tr>
> >                         <th>Contract User</th>
> >                         <td>
> >                             <html:checkbox property="contractUser"/>
> >                         </td>
> >                     </tr -->
> >
>
> Struts doesn't care of HTML comments, all the JSP source is processed to
> produce HTML content, and that's the navigator which is checking HTML
> comments to display contents or not.

But isn't JSP an XML based markup?  <!-- --> is used for comments in XML as 
well...


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


RE: Struts not parsing HTML correctly?

Posted by Jaye Bass <ja...@knology.net>.
Actually, you can use html comments to remove tags you just have to
embed them in the tag...thusly:

<!--bean:write name="foobar" property="nothing"-->

That will be ignored by the container, browser and everything else.


-----Original Message-----
From: Thomas CORNET [mailto:thomas@cornet.name] 
Sent: Tuesday, March 04, 2003 3:04 AM
To: Struts Users Mailing List
Subject: Re: Struts not parsing HTML correctly?

At 09:51 04/03/2003, you wrote:
>There are actually 2 problems I'm experiencing:
>
>Firstly, I have the following snippet in one of my forms
(user_add.jsp):
>
>                     <!-- tr>
>                         <th>Contract User</th>
>                         <td>
>                             <html:checkbox property="contractUser"/>
>                         </td>
>                     </tr -->
>
>If this is present, struts fails with the following error:
>
>org.apache.jasper.JasperException: No getter method for property
contractUser
>of bean org.apache.struts.taglib.html.BEAN
>
>This happens whether that section is commented out or not, but does not
occur
>if I remove the code entirely.

Struts doesn't care of HTML comments, all the JSP source is processed to

produce HTML content, and that's the navigator which is checking HTML 
comments to display contents or not.


>The second problem is that I actually DO have a getter (and setter)
method 
>for
>contractUser in UserForm.java:
>
>     /* Contract User */
>     private boolean contractUser = false;
>     public boolean getContractUser() {
>         return this.contractUser;
>     }
>     public void setContractUser(boolean contractUser) {
>         this.contractUser = contractUser;
>     }
>
>
>I have the following in my struts config:
>
><struts-config>
>     <form-beans>
>...
>         <form-bean name="userForm"
>                    type="com.somewhere.aproject.UserForm" />
>...
>     </form-beans>
>     <action-mappings>
>...
>         <action path="/screen_user_add"
>              forward="/user_add.jsp"
>                 name="userForm"
>             validate="false"/>
>...
>     </action-mappings>
></struts-config>
>
>
>I know the configuration is right since the rest of the fields work
fine.
>Should I be using type String instead of boolean for contractUser?

I've read somewhere that all forms fields should be declared as String
in 
the Form classes... It is recommended to make the conversions in your 
actions classes.


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



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


Re: Struts not parsing HTML correctly?

Posted by Thomas CORNET <th...@cornet.name>.
At 09:51 04/03/2003, you wrote:
>There are actually 2 problems I'm experiencing:
>
>Firstly, I have the following snippet in one of my forms (user_add.jsp):
>
>                     <!-- tr>
>                         <th>Contract User</th>
>                         <td>
>                             <html:checkbox property="contractUser"/>
>                         </td>
>                     </tr -->
>
>If this is present, struts fails with the following error:
>
>org.apache.jasper.JasperException: No getter method for property contractUser
>of bean org.apache.struts.taglib.html.BEAN
>
>This happens whether that section is commented out or not, but does not occur
>if I remove the code entirely.

Struts doesn't care of HTML comments, all the JSP source is processed to 
produce HTML content, and that's the navigator which is checking HTML 
comments to display contents or not.


>The second problem is that I actually DO have a getter (and setter) method 
>for
>contractUser in UserForm.java:
>
>     /* Contract User */
>     private boolean contractUser = false;
>     public boolean getContractUser() {
>         return this.contractUser;
>     }
>     public void setContractUser(boolean contractUser) {
>         this.contractUser = contractUser;
>     }
>
>
>I have the following in my struts config:
>
><struts-config>
>     <form-beans>
>...
>         <form-bean name="userForm"
>                    type="com.somewhere.aproject.UserForm" />
>...
>     </form-beans>
>     <action-mappings>
>...
>         <action path="/screen_user_add"
>              forward="/user_add.jsp"
>                 name="userForm"
>             validate="false"/>
>...
>     </action-mappings>
></struts-config>
>
>
>I know the configuration is right since the rest of the fields work fine.
>Should I be using type String instead of boolean for contractUser?

I've read somewhere that all forms fields should be declared as String in 
the Form classes... It is recommended to make the conversions in your 
actions classes.


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