Michael O'Cleirigh wrote:
>
> Hi Paul,
>
> Most of the wicket + javascript integrations in wicket-stuff
> (http://wicketstuff.org/confluence/display/STUFFWIKI/Wiki) will show how
> communication between wicket and javascript can work. They can get a
> little messy but once implemented are nice/simple to deal with since
> they are self contained.
>
> When the page is rendered custom javascript is also rendered that
> connects the component javascript (in your case the stock tree table)
> with the wicket components (in your case the hiddenField.getMarkupID()
> that will be used to fill in the selection details).
>
> This can be done by rendering out the wicket markup id details into a
> global variable in the DOM or as a property in a custom object in the DOM.
>
> In the case of Palette it uses its own DOM object called Wicket.Palette
> (see palette.js which is adjacent to Palette.java) This is where the
> work is done to move values between the choicesComponent and
> selectionComponent. The recorderComponent is a customized HiddenField
> that stores the list of values that are shown in the
> selectionComponent. The buttons are configured with onclick actions
> which are connected to the contextualized Wicket.Palette.action functions.
>
> Each of the Wicket.Palette.action functions expect three arguments:
> 1. the markup id of the choices component
> 2. the markup id of the selection component
> 3. the markup id of the recorder component.
>
> Which are filled in automatically for the palette being rendered.
>
> For your example you could create a custom hidden field like this and
> define the converter so that it will have a comma seperated string
> content but resolve into a list of Elements:
>
> new HiddenField<List<Element>>(id) {
>
>
> /* (non-Javadoc)
> * @see
> org.apache.wicket.Component#getConverter(java.lang.Class)
> */
> @Override
> public IConverter getConverter(Class<?> type) {
> return new IConverter() {
>
> @Override
> public String convertToString(List<Element>
> valueList, Locale locale) {
>
> // convert value list into a comma seperated
> string like A,B,C...
> return string;
> }
>
> @Override
> public Object convertToObject(String value, Locale
> locale) {
>
> // convert a comma seperated string A,B,C... back
> into the list of elements
> String[] elements = value.split(",");
>
> List<Element> elementList = new
> LinkedList<Element>();
>
> for (String e : elements) {
>
> // convert
> }
>
> return elementList;
> }
> };
> }};
>
> Then your javascript hooks for the on selection will append the id value
> of the selected element into the hidden field.
>
> When the form posts the formsubmittingComponent.onSubmit() action can
> just call hiddenField.getModelObject() to get the list of selected
> elements to process.
>
> Hope this helps you get started,
>
> Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
Hi, Mike - thank you very much for your reply. I am following the examples
on wicket-stuff and jweekend to write my own js tree-selector component. If
I shall finish it, I will post my code to this forum to thank all the help I
got.
--
View this message in context:
http://www.nabble.com/Client-side-treeView-tp25775360p25788264.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org