Nat: Yes. In dwr, I have <convert converter="bean"
match="com.model.*"/>.
My LabelValue object is in model directory.
getUserAsArrays from UserManager returns LabelValue array: LabelValue[].
What other wrapper class do I need to create? Here is my
UserManager.getUserAsArrays method.
public LabelValue[] getUserArrays() {
List userList = dao.getUsers();
int size = userList.size();
LabelValue[] userArrays = new LabelValue[size];
User user = null;
for (int i = 0; i < size; i++){
user = (User) userList.get(i);
userArrays [i] = new LabelValue(user.getId().toString(),
user.getFullName());
}
return userArrays;
}
Qin
________________________________
From: Nathaniel Rahav [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 18, 2007 11:42 AM
To: [email protected]
Subject: Re: [appfuse-user] Appfuse and DWR
Did you try creating a Wrapper Class for your return value and including
it in a <convert> tag in dwr.xml (or the annotations) ?
Nat
On 1/18/07, Ding, Qin <[EMAIL PROTECTED]> wrote:
Does anyone have the same experience as I do? If you do, please tell you
how you resolve this. I search internet and DWR archive, there is one
entry like this but no answers.
I use appfuse 1.9.4 and DWR to build two dependent dropdowns. Select
from frist dropdown will fill the second with the data pulled from
database. It works fine. But it only works when db returns simple array
of string. If db returns an array of Object like LabelValue object, I
got "object error".
Here is my dwr.xml:
------------------
<allow>
<create creator="spring" javascript="UserManager">
<param name="beanName" value="userManager"/>
<include method="getUserArrays"/>
</create>
<convert converter="bean" match="com.model.*"/>
</allow>
------------------
In dwr debug page, I can see my dwr call get data like following:
------------------
[
{
label:2,
labelValueAsString:label:2,value:Matt Raible,
value:Matt Raible,
}
{
label:1,
labelValueAsString:label:1,value:Tomcat User,
value:Tomcat User,
},
]
------------------
In my dummy.jsp here are javascript functions and dropdown html:
------------------
function loadUsers(){
UserManager.getUserArrays(fillUserDropdown);
}
function fillUserDropdown(data){
$("userDropdown").style.display = 'none';
DWRUtil.removeAllOptions("userDropdown ");
DWRUtil.addOptions(id, ["Please select..."]);
DWRUtil.addOptions('userDropdown', data, value, label);
$("userDropdown").style.display = '';
}
-----------------
<li>
<dma:label styleClass="desc" key="user.id"/>
<form:select id="userDropdown" path="id"></form:select>
</li>
<li>
<input type="button" value="load users" onclick=" loadUsers();"/>
</li>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]