You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Richard Hoberman <ri...@sadalbari.com> on 2008/02/05 23:47:12 UTC
Hidden input controls losing their position
Hi All
I want to track the order of list items that are re-ordered via
javascript. My proposed solution is to do something like this:
<html jwcid="@Shell" title="literal:Reordering Test Page">
<body jwcid="@Body">
<form jwcid="@Form">
<ul>
<li jwcid="@For" source="ognl:items"
value="ognl:currentItem">
<span jwcid="@Hidden" value="ognl:currentItem.index"
/> <!-- index simply identifies the order -->
//various item data displayed for user
</li>
</ul>
</form>
</body>
</html>
When the items are re-ordered, I'd fire of a javascript function, prior
to submission, that runs over the list and updates the hidden values so
that they again run from 1...n.
Now, on post back, the item.index properties will be updated and the
model thus re-ordered.
The problem with this is that Tapestry groups all hidden fields at the
start of their containing form control. Because they are outside of the
list I cannot (easily) update them based on the new order.
Is there are reason that Tapestry moves these controls? As far as I can
tell, it is perfectly legal to place an input control of type hidden
within any inline or block content.
Thanks
Richard Hoberman
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Hidden input controls losing their position
Posted by Richard Hoberman <ri...@sadalbari.com>.
Andreas Andreou wrote:
> One solution is this:
> Use one hidden for all the values...
> <span jwcid="order@Hidden" encode="false" value="ognl:ordering"/>
>
> Then, in java
> public String getOrdering() {return null}
> public void getOrdering(String value) { String[] order =
> value.split(','); ...... }
>
> Then have your javascript set that value correctly before submit
>
>
Thanks Andreas. That was my plan B. I thought it might be more elegant
(although perhaps less readable) to bind the hidden fields to the index
property of the model - the update would then be handled automatically
on the server side.
> Also, if you're having trouble understanding what the current order
> is, why not use specific ids
> in the list items? something like <li jwcid="@Any" id="ognl:'mylist'+index">
>
Took me a while to get this but that's a fine idea.
My "li" element is a For component so the current property value won't
yet be available for use in the ognl expression. I can deal with this
by setting the custom id on the first child of the "li".
Ultimately I think your first solution is better, because it doesn't
rely on any properties of the model. It's up to the server-side code to
decide how to implement the re-ordering.
Best regards
Richard
> On Feb 6, 2008 12:47 AM, Richard Hoberman
> <ri...@sadalbari.com> wrote:
>
>> Hi All
>>
>> I want to track the order of list items that are re-ordered via
>> javascript. My proposed solution is to do something like this:
>>
>> <html jwcid="@Shell" title="literal:Reordering Test Page">
>>
>> <body jwcid="@Body">
>>
>> <form jwcid="@Form">
>> <ul>
>> <li jwcid="@For" source="ognl:items"
>> value="ognl:currentItem">
>> <span jwcid="@Hidden" value="ognl:currentItem.index"
>> /> <!-- index simply identifies the order -->
>> //various item data displayed for user
>> </li>
>> </ul>
>> </form>
>>
>> </body>
>>
>> </html>
>>
>> When the items are re-ordered, I'd fire of a javascript function, prior
>> to submission, that runs over the list and updates the hidden values so
>> that they again run from 1...n.
>>
>> Now, on post back, the item.index properties will be updated and the
>> model thus re-ordered.
>>
>> The problem with this is that Tapestry groups all hidden fields at the
>> start of their containing form control. Because they are outside of the
>> list I cannot (easily) update them based on the new order.
>>
>> Is there are reason that Tapestry moves these controls? As far as I can
>> tell, it is perfectly legal to place an input control of type hidden
>> within any inline or block content.
>>
>> Thanks
>>
>> Richard Hoberman
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Hidden input controls losing their position
Posted by Andreas Andreou <an...@gmail.com>.
One solution is this:
Use one hidden for all the values...
<span jwcid="order@Hidden" encode="false" value="ognl:ordering"/>
Then, in java
public String getOrdering() {return null}
public void getOrdering(String value) { String[] order =
value.split(','); ...... }
Then have your javascript set that value correctly before submit
Also, if you're having trouble understanding what the current order
is, why not use specific ids
in the list items? something like <li jwcid="@Any" id="ognl:'mylist'+index">
On Feb 6, 2008 12:47 AM, Richard Hoberman
<ri...@sadalbari.com> wrote:
> Hi All
>
> I want to track the order of list items that are re-ordered via
> javascript. My proposed solution is to do something like this:
>
> <html jwcid="@Shell" title="literal:Reordering Test Page">
>
> <body jwcid="@Body">
>
> <form jwcid="@Form">
> <ul>
> <li jwcid="@For" source="ognl:items"
> value="ognl:currentItem">
> <span jwcid="@Hidden" value="ognl:currentItem.index"
> /> <!-- index simply identifies the order -->
> //various item data displayed for user
> </li>
> </ul>
> </form>
>
> </body>
>
> </html>
>
> When the items are re-ordered, I'd fire of a javascript function, prior
> to submission, that runs over the list and updates the hidden values so
> that they again run from 1...n.
>
> Now, on post back, the item.index properties will be updated and the
> model thus re-ordered.
>
> The problem with this is that Tapestry groups all hidden fields at the
> start of their containing form control. Because they are outside of the
> list I cannot (easily) update them based on the new order.
>
> Is there are reason that Tapestry moves these controls? As far as I can
> tell, it is perfectly legal to place an input control of type hidden
> within any inline or block content.
>
> Thanks
>
> Richard Hoberman
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org