You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <ma...@qat.com> on 2003/05/24 22:14:53 UTC
Mapped-backed ActionForms and DynaActionForms
It seems reasonable that if I define a property in struts-config as
<form-property name="taxi_limo_sun" type="java.util.Map"/>
I should be able to set it in the associated Action with
adminForm.set( "taxi_limo_sun", id, data[ j ] );
following the overridden DynaActionForm set method with String,String,Object
parameter, but am getting a run-time NullPointerException: No mapped value
for 'taxi_limo_sun(id_0)'.
Is this because DynaActionForms cannot handle type Map? If not, what is the
value of this set method?
tia,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Mapped-backed ActionForms and DynaActionForms
Posted by Ted Husted <hu...@apache.org>.
Mark Galbreath wrote:
> Thanks, Ted - I figured that out without having to resort to looking at the
> source.
Actually, I knew that you did. We probably discovered your problem in
the same instant in time. But I sent the message anyway, since it was a
good opportunity to remind people that Struts is a open-source product,
not a blackbox. And, since it's Sunday, I'll preach a bit [like I
actually need an excuse :o)]
Since Struts is targeted for developers, theoretically, there's nothing
in Struts that most of us couldn't have written for ourselves. (One way
or the other.) The first place any developer on this list should look
for advice is the code itself. If someone is getting an exception
message, but are not sure why, the source is a search key away.
And, if you're using a decent IDE, like IDEA by IntelliJ, poking through
the code has never been easier. From any entry point, you can zip back
through the code, down to the Java libraries themselves. When I started
with Struts, finding your way through a complex codebase like this, was
difficult and timeconsuming. But with the tools we have now, it's almost
child's play. More than ever before, we can all "Use the source."
-Ted.
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Mapped-backed ActionForms and DynaActionForms
Posted by Mark Galbreath <ma...@qat.com>.
Then again, maybe not.... :-(
-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Saturday, May 24, 2003 5:57 PM
To: 'Struts Users Mailing List'
Subject: RE: Mapped-backed ActionForms and DynaActionForms
Doh! Just looking over my code I see the error. The <bean:write> should be
referencing the iterator.
Mark
-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Saturday, May 24, 2003 5:51 PM
To: 'Struts Users Mailing List'
Subject: RE: Mapped-backed ActionForms and DynaActionForms
Thanks, Ted - I figured that out without having to resort to looking at the
source. Not that I wouldn't do that normally ("normal?"), but I am under
tremendous pressure to get working "showcase" Struts app to my client, so I
try the path of least resistance (hopefully).
Also, glad to see you and James are working (?) over the holiday as I am.
Now, I need some help in getting this into HTML. When I do this:
<logic:present name="adminForm" scope="session">
<logic:iterate name="adminForm" property="id" id="id">
Expense Report for <bean:write name="adminForm" property="id" />
<jsp:include page="admin_travel.jsp" flush="true"/>
</logic:iterate>
</logic:present>
The <bean:write> writes out all the userIds in the HashMap. What I need is
to have a userId at the head of every admin_travel_jsp page output with the
users' respective data in each iteration. Is there a fine-grain way to do
this without resorting to scripting?
tia,
mark
-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Saturday, May 24, 2003 4:52 PM
To: Struts Users Mailing List
Subject: Re: Mapped-backed ActionForms and DynaActionForms
Mark Galbreath wrote:
> It seems reasonable that if I define a property in struts-config as > >
<form-property name="taxi_limo_sun" type="java.util.Map"/> > > I should be
able to set it in the associated Action with > > adminForm.set(
"taxi_limo_sun", id, data[ j ] ); > > following the overridden
DynaActionForm set method with
String,String,Object
> parameter, but am getting a run-time NullPointerException: No mapped
value
> for 'taxi_limo_sun(id_0)'.
>
> Is this because DynaActionForms cannot handle type Map? If not, what
is the
> value of this set method?
Maps are supported:
[org.apache.struts.action.DynaActionForm]
public void set(String name, String key, Object value) {
Object prop = dynaValues.get(name);
if (prop == null) {
throw new NullPointerException
("No mapped value for '" + name + "(" + key + ")'");
} else if (prop instanceof Map) {
((Map) prop).put(key, value);
} else {
throw new IllegalArgumentException
("Non-mapped property for '" + name + "(" + key + ")'");
}
}
But you need to specify a concrete implementation. Map is an interface.
-Ted.
>
> tia,
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Mapped-backed ActionForms and DynaActionForms
Posted by Mark Galbreath <ma...@qat.com>.
Doh! Just looking over my code I see the error. The <bean:write> should be
referencing the iterator.
Mark
-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Saturday, May 24, 2003 5:51 PM
To: 'Struts Users Mailing List'
Subject: RE: Mapped-backed ActionForms and DynaActionForms
Thanks, Ted - I figured that out without having to resort to looking at the
source. Not that I wouldn't do that normally ("normal?"), but I am under
tremendous pressure to get working "showcase" Struts app to my client, so I
try the path of least resistance (hopefully).
Also, glad to see you and James are working (?) over the holiday as I am.
Now, I need some help in getting this into HTML. When I do this:
<logic:present name="adminForm" scope="session">
<logic:iterate name="adminForm" property="id" id="id">
Expense Report for <bean:write name="adminForm" property="id" />
<jsp:include page="admin_travel.jsp" flush="true"/>
</logic:iterate>
</logic:present>
The <bean:write> writes out all the userIds in the HashMap. What I need is
to have a userId at the head of every admin_travel_jsp page output with the
users' respective data in each iteration. Is there a fine-grain way to do
this without resorting to scripting?
tia,
mark
-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Saturday, May 24, 2003 4:52 PM
To: Struts Users Mailing List
Subject: Re: Mapped-backed ActionForms and DynaActionForms
Mark Galbreath wrote:
> It seems reasonable that if I define a property in struts-config as > >
<form-property name="taxi_limo_sun" type="java.util.Map"/> > > I should be
able to set it in the associated Action with > > adminForm.set(
"taxi_limo_sun", id, data[ j ] ); > > following the overridden
DynaActionForm set method with
String,String,Object
> parameter, but am getting a run-time NullPointerException: No mapped
value
> for 'taxi_limo_sun(id_0)'.
>
> Is this because DynaActionForms cannot handle type Map? If not, what
is the
> value of this set method?
Maps are supported:
[org.apache.struts.action.DynaActionForm]
public void set(String name, String key, Object value) {
Object prop = dynaValues.get(name);
if (prop == null) {
throw new NullPointerException
("No mapped value for '" + name + "(" + key + ")'");
} else if (prop instanceof Map) {
((Map) prop).put(key, value);
} else {
throw new IllegalArgumentException
("Non-mapped property for '" + name + "(" + key + ")'");
}
}
But you need to specify a concrete implementation. Map is an interface.
-Ted.
>
> tia,
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
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: Mapped-backed ActionForms and DynaActionForms
Posted by Mark Galbreath <ma...@qat.com>.
Thanks, Ted - I figured that out without having to resort to looking at the
source. Not that I wouldn't do that normally ("normal?"), but I am under
tremendous pressure to get working "showcase" Struts app to my client, so I
try the path of least resistance (hopefully).
Also, glad to see you and James are working (?) over the holiday as I am.
Now, I need some help in getting this into HTML. When I do this:
<logic:present name="adminForm" scope="session">
<logic:iterate name="adminForm" property="id" id="id">
Expense Report for <bean:write name="adminForm" property="id" />
<jsp:include page="admin_travel.jsp" flush="true"/>
</logic:iterate>
</logic:present>
The <bean:write> writes out all the userIds in the HashMap. What I need is
to have a userId at the head of every admin_travel_jsp page output with the
users' respective data in each iteration. Is there a fine-grain way to do
this without resorting to scripting?
tia,
mark
-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Saturday, May 24, 2003 4:52 PM
To: Struts Users Mailing List
Subject: Re: Mapped-backed ActionForms and DynaActionForms
Mark Galbreath wrote:
> It seems reasonable that if I define a property in struts-config as > >
<form-property name="taxi_limo_sun" type="java.util.Map"/> > > I should be
able to set it in the associated Action with > > adminForm.set(
"taxi_limo_sun", id, data[ j ] ); > > following the overridden
DynaActionForm set method with
String,String,Object
> parameter, but am getting a run-time NullPointerException: No mapped
value
> for 'taxi_limo_sun(id_0)'.
>
> Is this because DynaActionForms cannot handle type Map? If not, what
is the
> value of this set method?
Maps are supported:
[org.apache.struts.action.DynaActionForm]
public void set(String name, String key, Object value) {
Object prop = dynaValues.get(name);
if (prop == null) {
throw new NullPointerException
("No mapped value for '" + name + "(" + key + ")'");
} else if (prop instanceof Map) {
((Map) prop).put(key, value);
} else {
throw new IllegalArgumentException
("Non-mapped property for '" + name + "(" + key + ")'");
}
}
But you need to specify a concrete implementation. Map is an interface.
-Ted.
>
> tia,
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
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: Mapped-backed ActionForms and DynaActionForms
Posted by Ted Husted <hu...@apache.org>.
Mark Galbreath wrote:
> It seems reasonable that if I define a property in struts-config as
>
> <form-property name="taxi_limo_sun" type="java.util.Map"/>
>
> I should be able to set it in the associated Action with
>
> adminForm.set( "taxi_limo_sun", id, data[ j ] );
>
> following the overridden DynaActionForm set method with
String,String,Object
> parameter, but am getting a run-time NullPointerException: No mapped
value
> for 'taxi_limo_sun(id_0)'.
>
> Is this because DynaActionForms cannot handle type Map? If not, what
is the
> value of this set method?
Maps are supported:
[org.apache.struts.action.DynaActionForm]
public void set(String name, String key, Object value) {
Object prop = dynaValues.get(name);
if (prop == null) {
throw new NullPointerException
("No mapped value for '" + name + "(" + key + ")'");
} else if (prop instanceof Map) {
((Map) prop).put(key, value);
} else {
throw new IllegalArgumentException
("Non-mapped property for '" + name + "(" + key + ")'");
}
}
But you need to specify a concrete implementation. Map is an interface.
-Ted.
>
> tia,
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org