Hi Eli,

es wrote:

> Greetings community! (when next get-together  ?)
>
> I need help/advices to automatically bind beans populated by CForm and
> an OpenOffice  Calc spreadsheet.
> The fields are a lot (150 or more) now I wonder if there is a more
> clever idea then to do ooCalcWrapper.setCellValue( "C15",
> bean.getC15()) for 150 different fields.
> Since a lot these cells are simple cellranges like C15:C30 I'm sure
> there is a way (how?) I can iterate the cellranges horizzontaly or
> vertically and set/get the value and fill a Collection.
> Then I can use reflection to discover the get/set method of the bean
> and doing a binding.

If you need to take a bean and output a .xsl / .sxc file, maybe
serializing the bean to XML (there are many serializers available, from
the XMLEncoder which is bundled with JRE but is a bit floppy, to the
excellent XStreams, you could write a generator to do this, put it in a
pipeline and call it from the flow), then transforming the XML thru an
XSL and then using the HSSF serializer (look here
http://cocoon.apache.org/2.1/userdocs/xls-serializer.html ) can be a
good solution. It depends on how the bean is made, and how it have to be
mapped in the XSL file.

An XStreams generator is about 5/10 lines long, and could also be a good
contribution to cocoon, all the rest il plain old XSL.

>
> Another thing:
> Looking at the samples I've see that they way CForm can build up a
> dropdown list is using Enum. I wonder how can I generate it
> dynamically and how can I set the selected option on loading, since I
> need to get it from the underlying spreadsheet.

The Enum pattern is based on class fields, so if not using BCEL or ASM
or code generation, i don't think there is a easy way to have runtime
generated enums.

But actually, enum is just one of the way to build a dropdown in cocoon
forms. You can also :
- Implement your own SelectionList in java and use it inside you forms.
- Use one of the already made selection lists that can be populated at
runtime (the FlowJXPathSelectionList or JavaScriptSelectionList).
- Use <fd:selection-list
src="cocoon://pipe/that/generates/a/selection/list"/> and then use
whatever you want in that pipe, even a flow.


Hope this helps,

Simone

-- 
Simone Gianni

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to