You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastien Arbogast <se...@gmail.com> on 2005/05/02 14:48:03 UTC
Object list form ?
Hi,
For the moment I've built my simple forms using documentation examples
but now I need to do something new and I didn't find any documentation
or sample to illustrate that.
I'd like to display a form containing a list of items, each item
corresponding to a value object I get from flowscript through Spring.
In other words I would like to :
1 - get the list of value object from Spring layer
2 - build my form model (of which I don't know the size 'a priori')
3 - populate my model with data from the value objects in the list
4 - display the form
It's the dynamic model and the data binding aspects that make me
uncomfortable above all.
Any idea or simple procedure ?
Thx in advance.
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Re[6]: Object list form ?
Posted by Sebastien Arbogast <se...@gmail.com>.
Ok this is what I've tried so far. You will find the three form files
attached. And the flowscript function is the following :
function displayUsersList(){
getUsers();
var usersList = users.getAllUsers();
var form = new Form("users_d.xml");
form.createBinding("users_b.xml");
form.load(usersList);
form.showForm("displayUsersForm");
}
And here is the concerned pipeline :
<map:pipeline internal-only="true">
<map:act type="locale">
<map:match pattern="internal/*">
<map:generate src="pages/{1}.xml"/>
<map:call resource="apply-theme">
<map:parameter name="includemenu" value="true"/>
</map:call>
</map:match>
</map:act>
</map:pipeline>
Of course it doesn't work I'm sure I miss a few things but I don't
know where. Here is the exception I get :
An Error Occurred
No Cocoon Form found.
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.xml.sax.SAXException: No Cocoon Form found.
cause: org.xml.sax.SAXException: No Cocoon Form found.
full exception chain stacktrace[hide]
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.xml.sax.SAXException: No Cocoon Form found.
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.handleException(AbstractProcessingPipeline.java:940)
at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:281)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:483)
at org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:120)
...
Any idea ?
Thx in advance.
--
Sebastien ARBOGAST
Re[6]: Object list form ?
Posted by Jens Maukisch <co...@maukisch.net>.
Hi Sebastien,
> But the problem with this is how do I get data back from "users-list"
> form page ? How to get POST parameters ?
> And over all, which solution is more elegant : CForm (if possible) or
> ordinary HTML form ?
> WDYT ?
We've used CForms for this.
function displayUsers(){
var users = usersService.findAllUsers();
var form = new Form("model.xml");
form.createBinding("binding.xml");
form.load(users);
form.showForm("displayUsersForm");
// get the repeater widget from the form an look which
// users are selected and get the corresponding bean
// from the users collection and do whatever you want to do :-)
// maybe dependend on form.submitId
}
In the form-model you can use a fd:booleanfield for the selection
and fd:output-fields to display the username inside the
repeater-widget.
hth
--
* best regards
* Jens Maukisch
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Re[4]: Object list form ?
Posted by Sebastien Arbogast <se...@gmail.com>.
> Hi Sebastien,
>
> >> Are you looking for the repeater-widget?
> >> http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater.html
>
> > Not exactly. I know this widget but my problem is more how to build my
> > form from flowscript than writing the form model itself... :(
>
> Hmm, so it seems that I don't understand your problem correctly.
>
> So you have a collection of user-objects and you want to show
> them to the user so that he can select one or more to do further
> actions on them?
>
> So you want to display a checkbox and some other information from
> the user-objects (e.g. first- and lastname)?
Exactly ! A very good example of what I would like to achieve in the
first place is GMail main frame, except that instead of listing
emails, I want to list users (for now). But it's exactly the kind of
interface I'm trying to make : a list of entities with actions to
apply on selected ones, etc.
It seems to be something quite common in web applications.
But I'm beginning to think of making a HTML form directly, using a
JXTemplate, since validation is not a big issue. This way I could just
do something like that in flowscript :
function displayUsers(){
var users = usersService.findAllUsers();
cocoon.sendPageAndWait("users-list",{list : users});
...
}
But the problem with this is how do I get data back from "users-list"
form page ? How to get POST parameters ?
And over all, which solution is more elegant : CForm (if possible) or
ordinary HTML form ?
WDYT ?
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re[4]: Object list form ?
Posted by Jens Maukisch <co...@maukisch.net>.
Hi Sebastien,
>> Are you looking for the repeater-widget?
>> http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater.html
> Not exactly. I know this widget but my problem is more how to build my
> form from flowscript than writing the form model itself... :(
Hmm, so it seems that I don't understand your problem correctly.
So you have a collection of user-objects and you want to show
them to the user so that he can select one or more to do further
actions on them?
So you want to display a checkbox and some other information from
the user-objects (e.g. first- and lastname)?
--
* best regards
* Jens Maukisch
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Re[2]: Object list form ?
Posted by Sebastien Arbogast <se...@gmail.com>.
> Are you looking for the repeater-widget?
> http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater.html
Not exactly. I know this widget but my problem is more how to build my
form from flowscript than writing the form model itself... :(
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re[2]: Object list form ?
Posted by Jens Maukisch <co...@maukisch.net>.
Hi Sebastien,
> Ok you're right I should have precised. In fact what I want to display
> is something like the list of email messages in Google, in a table,
> with a checkbox for each line (to select items to apply actions on)
> and just a few details about the item so that I can edit it. For
> example I would like to obtain some HTML code like this at the end :
Are you looking for the repeater-widget?
http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater.html
--
* best regards
* Jens Maukisch
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Object list form ?
Posted by Sebastien Arbogast <se...@gmail.com>.
> I'm not sure what you mean by 'list' here. Is it a drop-down listbox as
> in the HTML <select> element?
Ok you're right I should have precised. In fact what I want to display
is something like the list of email messages in Google, in a table,
with a checkbox for each line (to select items to apply actions on)
and just a few details about the item so that I can edit it. For
example I would like to obtain some HTML code like this at the end :
<form action="..." method="post">
<table>
<tr>
<td><input type="checkbox" id="user_select[1]"/></td>
<td><a href="edit_user_1">User1</a></td>
</tr>
<tr>
<td><input type="checkbox" id="user_select[2]"/></td>
<td><a href="edit_user_2">User2</a></td>
</tr>
...
<tr>
<td colspan="2"><input type="submit"/></td>
</table>
</form>
And my problem is that
1 - I don't know the number of lines in the table before I load the user list
2 - I don't know how to populate the form with the right information
(eg to put user names instead of "UserN")
As you may have guessed I need that for some backend application to
manage a set of users.
> > In other words I would like to :
> > 1 - get the list of value object from Spring layer
> > 2 - build my form model (of which I don't know the size 'a priori')
> > 3 - populate my model with data from the value objects in the list
> > 4 - display the form
> >
> > It's the dynamic model and the data binding aspects that make me
> > uncomfortable above all.
>
> Assuming your value objects are defined somewhat like:
>
> public class Item {
> public String getKey();
> public String getValue();
> }
>
> Then your flowscript code should be liike:
>
> var aList = getTheList(); // via Spring, returns a List of Item's
> form.lookupWidget("theSelectField").setSelectionList(aList, "key",
> "value");
Anyway this is very useful and I'm sure I will need it somewhere further.
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Object list form ?
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 02/mag/05, alle 14:48, Sebastien Arbogast ha scritto:
> I'd like to display a form containing a list of items, each item
> corresponding to a value object I get from flowscript through Spring.
I'm not sure what you mean by 'list' here. Is it a drop-down listbox as
in the HTML <select> element?
> In other words I would like to :
> 1 - get the list of value object from Spring layer
> 2 - build my form model (of which I don't know the size 'a priori')
> 3 - populate my model with data from the value objects in the list
> 4 - display the form
>
> It's the dynamic model and the data binding aspects that make me
> uncomfortable above all.
Assuming your value objects are defined somewhat like:
public class Item {
public String getKey();
public String getValue();
}
Then your flowscript code should be liike:
var aList = getTheList(); // via Spring, returns a List of Item's
form.lookupWidget("theSelectField").setSelectionList(aList, "key",
"value");
Ugo
--
Ugo Cei
Tech Blog: http://agylen.com/
Source.zone: http://sourcezone.info/
Wine & Food Blog: http://www.divinocibo.it/