You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nadja Senoucci <se...@21st.de> on 2003/06/17 15:41:31 UTC

Problem with Map based form

Hello everyone,

I am having a weird error with one of my Map based forms. I have these
fields in my form:

<html:text property="value(getKostenstelle)"/>
<html:text property="value(getBezeichnung)"/>

And I have the corresponding get-/set-methods in my form bean:

public void setValue(String key, Object value){
  values.put(key,value);
  LoggerSupport.logDebug("values: "+key+"->"+value.toString(),log);
}

public String getValue(String key){
  String temp;
  if(values==null){
    return "";
  }else if((temp = (String)values.get(key))==null){
    temp = "";
  }
  return temp;
}

values is my Map and it is being initialized in the form's contructor.

Now, I want to validate the date in my validate method. But when the
programm reaches method TreeMap is empty. In fact, you can see I have
inserted some debugging info (that get's written in my logging file) in my
set-method. When I open my logging file those lines are nowhere to be found,
meaning the set-method does not get called before the programm reaches
validate. But as far as I know it should've been long called, or am I wrong?

The funny thing is, I've been using Map based forms before and those worked
just fine and I can't see what I am doing differently here...

I'd be grateful for any kind of help with this.

Greetings,
Nadja



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


Re: Problem with Map based form

Posted by Nadja Senoucci <se...@21st.de>.
Hello Dirk,

>  perhaps you have 2 forms in different scopes? Session and request?

No, all my forms are in request scope.

(And sorry about sending that email to your email address, I seem to
continually forget about checking the reply-to...)

Greetings,
Nadja



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


Re: Problem with Map based form

Posted by Dirk Markert <di...@dr-markert.de>.
Hallo Nadja,

  perhaps you have 2 forms in different scopes? Session and request?


Regards,
Dirk  


***************************************************************

NS> Hello everyone,

NS> I am having a weird error with one of my Map based forms. I have these
NS> fields in my form:

NS> <html:text property="value(getKostenstelle)"/>
NS> <html:text property="value(getBezeichnung)"/>

NS> And I have the corresponding get-/set-methods in my form bean:

NS> public void setValue(String key, Object value){
NS>   values.put(key,value);
NS>   LoggerSupport.logDebug("values: "+key+"->"+value.toString(),log);
NS> }

NS> public String getValue(String key){
NS>   String temp;
NS>   if(values==null){
NS>     return "";
NS>   }else if((temp = (String)values.get(key))==null){
NS>     temp = "";
NS>   }
NS>   return temp;
NS> }

NS> values is my Map and it is being initialized in the form's contructor.

NS> Now, I want to validate the date in my validate method. But when the
NS> programm reaches method TreeMap is empty. In fact, you can see I have
NS> inserted some debugging info (that get's written in my logging file) in my
NS> set-method. When I open my logging file those lines are nowhere to be found,
NS> meaning the set-method does not get called before the programm reaches
NS> validate. But as far as I know it should've been long called, or am I wrong?

NS> The funny thing is, I've been using Map based forms before and those worked
NS> just fine and I can't see what I am doing differently here...

NS> I'd be grateful for any kind of help with this.

NS> Greetings,
NS> Nadja



NS> ---------------------------------------------------------------------
NS> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
NS> 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: Problem with Map based form

Posted by Nadja Senoucci <se...@21st.de>.
Hello again,

I found out what hindered it from working. I still don't understand why that
would be a problem - or more correctly why it this problem would show the
symptoms I got - but it was the only thing I've changed so it had to be this.

> public String getValue(String key){
>  String temp;
>  if(values==null){
>    return "";
>  }else if((temp = (String)values.get(key))==null){
>    temp = "";
>  }
>  return temp;
> }

This method had the wrong return value, had to be Object.

Greetings,
Nadja



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