You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by OJ...@gmx.de on 2005/09/09 14:53:51 UTC

ActionForm Problem

Hi@all

I have a problem with my Form Bean:

On my jsp I have have a List of values and put them on my jsp with this code

<table border="0" >
<html:form action="/saveFVKNAction" method="post" >
<logic:iterate name="fvknList" id="line" indexId="lineNo"
type="de.srs.pen.dao.base.FormValueKeyName">

<tr>
<td><%=lineNo.intValue()+1%></td>
<td><bean:write name="line" property="fieldName"  filter="true" /></td>
<td><html:text  name="line" property="dispName"   indexed="true" 
size="15"/></td>
<td><bean:write name="line" property="dispLang"   filter="true"/></td>
<td><html:text  name="line" property="sortOrder"  indexed="true" 
size="3"/></td>
<td><bean:write name="line" property="lastUpdate" filter="true"
format="dd.MM.yyyy HH:mm:ss" /></td>
</tr>
</logic:iterate>
</table>
<html:submit value="store" />


I get those values I want on my JSP. I tried to get those values into my
ActionForm with indexed properties but it wont work, I dont now why....here
is my code from my action form, I have a few log.debug() in it so that I can
see if it works but none of my log.debug() shows up.

public class SaveFVKNForm extends ActionForm {

private Logger log = Logger.getLogger(LoginAction.class);

    private List fvknListIndexed;
    
    
    /** 
     * Method validate
     * @param mapping
     * @param request
     * @return ActionErrors
     */
    public ActionErrors validate(
        ActionMapping mapping,
        HttpServletRequest request) {

        return new ActionErrors();
    }

    /** 
     * Method reset
     * @param mapping
     * @param request
     */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
       log.debug("FORM RESET");
    	fvknListIndexed = new ArrayList();
    }

    /**
     * @return Returns the formFieldIndexed.
     */
    public FormValueKeyName getFvknList(int idx) {
    	log.debug("FORM getFVKN");
    	if( fvknListIndexed == null ) 
            fvknListIndexed = new ArrayList();
        
        resizeList(idx);
        
        if( fvknListIndexed.size() > idx )
            return (FormValueKeyName) fvknListIndexed.get(idx);
        else 
            return new FormValueKeyName();
    }
    /**
     * @param formFieldIndexed The formFieldIndexed to set.
     */
    public void setFvknList(int idx, FormValueKeyName field) {
    	log.debug("FORM set FVKNFIELD");
    	if( fvknListIndexed == null ) 
            fvknListIndexed = new ArrayList();
        
        resizeList(idx);
        
        if( fvknListIndexed.size() > idx )
            this.fvknListIndexed.set(idx, field);
        else
            throw new RuntimeException("Index out of bounds!");
    }

    /**
     * @param fieldList
     */
    public void setFvknList(List fieldList) {
    	log.debug("FORM SET FIELDLIEST");
    	this.fvknListIndexed = fieldList;
    }
    /**
     * @param fieldList
     */
    public List getFieldList() {
    	log.debug("FORM getFieldlist");
    	if( fvknListIndexed == null ) 
            fvknListIndexed = new ArrayList();
        
        return this.fvknListIndexed;
    }


In my Action I want to get those values into my logfile but the List is
empty....

here is my action

SaveFVKNForm saveFVKNForm =  new SaveFVKNForm();
Integer size = new Integer(saveFVKNForm.getFieldList().size());
		
log.info(size.toString());
		
for (int i=0; i<saveFVKNForm.getFieldList().size();i++)
{
FormValueKeyName row = (FormValueKeyName) saveFVKNForm.getFvknList(i);
log.info("Field Name: "+row.getFieldName()+" Disp: "+row.getDispName()+"
Order"+row.getSortOrder());
		}
		

Does anyone see my mistake(s) 

Thanks for your help


-- 
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse f�r Mail, Message, More +++

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


Re: ActionForm Problem

Posted by Laurie Harper <la...@holoweb.net>.
You're not seeing any data in your action because your JSP doesn't 
contain anything that would submit data. You have a form in your JSP, 
but no input elements: all your data is just written to the page as 
static text.

If you want a form to submit data, that form needs to include HTML input 
elements that allow the data to be entered. If you don't actually need 
the user to be able to edit or enter data, you can use 'hidden' form 
fields to specify what should be submitted with the form.

See Struts' HTML tag library [1] for a set of tags that help you build 
forms and bind them to server-side data. See the Struts User Guide [2] 
for more detail, particularly the sections on bulding view components [3].

L.

[1] http://struts.apache.org/userGuide/building_view.html
[2] http://struts.apache.org/userGuide/index.html
[3] http://struts.apache.org/userGuide/building_view.html

OJAY78@gmx.de wrote:
> Hi@all
> 
> I have a problem with my Form Bean:
> 
> On my jsp I have have a List of values and put them on my jsp with this code
> 
> <table border="0" >
> <html:form action="/saveFVKNAction" method="post" >
> <logic:iterate name="fvknList" id="line" indexId="lineNo"
> type="de.srs.pen.dao.base.FormValueKeyName">
> 
> <tr>
> <td><%=lineNo.intValue()+1%></td>
> <td><bean:write name="line" property="fieldName"  filter="true" /></td>
> <td><html:text  name="line" property="dispName"   indexed="true" 
> size="15"/></td>
> <td><bean:write name="line" property="dispLang"   filter="true"/></td>
> <td><html:text  name="line" property="sortOrder"  indexed="true" 
> size="3"/></td>
> <td><bean:write name="line" property="lastUpdate" filter="true"
> format="dd.MM.yyyy HH:mm:ss" /></td>
> </tr>
> </logic:iterate>
> </table>
> <html:submit value="store" />
> 
> 
> I get those values I want on my JSP. I tried to get those values into my
> ActionForm with indexed properties but it wont work, I dont now why....here
> is my code from my action form, I have a few log.debug() in it so that I can
> see if it works but none of my log.debug() shows up.
> 
> public class SaveFVKNForm extends ActionForm {
> 
> private Logger log = Logger.getLogger(LoginAction.class);
> 
>     private List fvknListIndexed;
>     
>     
>     /** 
>      * Method validate
>      * @param mapping
>      * @param request
>      * @return ActionErrors
>      */
>     public ActionErrors validate(
>         ActionMapping mapping,
>         HttpServletRequest request) {
> 
>         return new ActionErrors();
>     }
> 
>     /** 
>      * Method reset
>      * @param mapping
>      * @param request
>      */
>     public void reset(ActionMapping mapping, HttpServletRequest request) {
>        log.debug("FORM RESET");
>     	fvknListIndexed = new ArrayList();
>     }
> 
>     /**
>      * @return Returns the formFieldIndexed.
>      */
>     public FormValueKeyName getFvknList(int idx) {
>     	log.debug("FORM getFVKN");
>     	if( fvknListIndexed == null ) 
>             fvknListIndexed = new ArrayList();
>         
>         resizeList(idx);
>         
>         if( fvknListIndexed.size() > idx )
>             return (FormValueKeyName) fvknListIndexed.get(idx);
>         else 
>             return new FormValueKeyName();
>     }
>     /**
>      * @param formFieldIndexed The formFieldIndexed to set.
>      */
>     public void setFvknList(int idx, FormValueKeyName field) {
>     	log.debug("FORM set FVKNFIELD");
>     	if( fvknListIndexed == null ) 
>             fvknListIndexed = new ArrayList();
>         
>         resizeList(idx);
>         
>         if( fvknListIndexed.size() > idx )
>             this.fvknListIndexed.set(idx, field);
>         else
>             throw new RuntimeException("Index out of bounds!");
>     }
> 
>     /**
>      * @param fieldList
>      */
>     public void setFvknList(List fieldList) {
>     	log.debug("FORM SET FIELDLIEST");
>     	this.fvknListIndexed = fieldList;
>     }
>     /**
>      * @param fieldList
>      */
>     public List getFieldList() {
>     	log.debug("FORM getFieldlist");
>     	if( fvknListIndexed == null ) 
>             fvknListIndexed = new ArrayList();
>         
>         return this.fvknListIndexed;
>     }
> 
> 
> In my Action I want to get those values into my logfile but the List is
> empty....
> 
> here is my action
> 
> SaveFVKNForm saveFVKNForm =  new SaveFVKNForm();
> Integer size = new Integer(saveFVKNForm.getFieldList().size());
> 		
> log.info(size.toString());
> 		
> for (int i=0; i<saveFVKNForm.getFieldList().size();i++)
> {
> FormValueKeyName row = (FormValueKeyName) saveFVKNForm.getFvknList(i);
> log.info("Field Name: "+row.getFieldName()+" Disp: "+row.getDispName()+"
> Order"+row.getSortOrder());
> 		}
> 		
> 
> Does anyone see my mistake(s) 
> 
> Thanks for your help
> 
> 


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