Re: Repetition and OnClick of TR
Re: Repetition and OnClick of TR
- Subject: Re: Repetition and OnClick of TR
- From: Jean-François Veillette <email@hidden>
- Date: Thu, 12 Jan 2006 15:10:41 -0500
Alex gave you an excellent solution that is simpler than the one following, but I'll give it just in case you cant afford to navigate the dom tree (which might not always be an option).
With explicit reference to the link object :
<x-tad-bigger><tr onClick="document.location=getElementById('<webobject name=HyperLinkID></webobject>').href;">
...</x-tad-bigger><x-tad-bigger>
</x-tad-bigger><x-tad-bigger><td colspan="2"></x-tad-bigger><x-tad-bigger><webobject name=EditLink></webobject></x-tad-bigger><x-tad-bigger></td>
...</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
HyperLinkID: WOString {
value = uniqueLineId;
}
EditLink: WOHyperlink {
action = editItem;
...
id = uniqueLineId;
}
where uniqueLineId is a java function defined to produce a unique html-dom id string.
As you can see, it's the same idea, but access the link explicitely, where Alex's solution access the link in a dom-relative way.
I've never tried the WOGenericContainer option.
- jfv
Le 06-01-12, à 13:36, Alex Johnson a écrit :
I recommend having doing something like this:
<x-tad-bigger><tr onclick="window.location=this.getElementsByTagName('a')[0].href"><td><webobject name="WOHyperlink1"></webobject>
</x-tad-bigger>
or
<x-tad-bigger><tr onclick="window.location=this.childNodes[0].childNodes[0].href"><td><webobject name="WOHyperlink1"></webobject>
</x-tad-bigger>
Where WOHyperlink1's <x-tad-bigger>action</x-tad-bigger> is bound to <x-tad-bigger>editLink</x-tad-bigger>. If you use the latter, watch out for textnodes (aka white-space). Whichever one you use, you'll probably want to make the <x-tad-bigger>onclick</x-tad-bigger> a little more robust, but these should point you in the right direction.
The other option, I think, might be to use WOGenericContainer for the <x-tad-bigger><tr></x-tad-bigger> tag, binding <x-tad-bigger>invokeAction</x-tad-bigger> to <x-tad-bigger>editLink</x-tad-bigger> and <x-tad-bigger>onclick</x-tad-bigger> to a method that returns <x-tad-bigger>"window.location='" + context().componentActionUrl() + "'"</x-tad-bigger>, but I have never tried this.
Alex Johnson
|| | ||| || | ||| | | | || || |||
\\ SITE 9 \\ SITE9.COM \\ 503.248.4440 \\
On Jan 11, 2006, at 5:59 PM, Dave Elsner wrote:
Hi,
Does any one have an easy solution to place a javascript onClick of a table row thats in a <x-tad-bigger>WORepeition</x-tad-bigger>
the Action i need to call is:
<x-tad-bigger>public</x-tad-bigger><x-tad-bigger> WOComponent editLink()</x-tad-bigger>
<x-tad-bigger> {</x-tad-bigger>
<x-tad-bigger>editFlag = </x-tad-bigger><x-tad-bigger>true</x-tad-bigger><x-tad-bigger>;</x-tad-bigger>
my<x-tad-bigger>DisplayGroup.selectObject(aItem);</x-tad-bigger>
<x-tad-bigger> </x-tad-bigger><x-tad-bigger>return</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>this</x-tad-bigger><x-tad-bigger>.context().page();</x-tad-bigger>
<x-tad-bigger> }</x-tad-bigger>
I tried adding:
<x-tad-bigger>public</x-tad-bigger><x-tad-bigger> String onClickLocation()</x-tad-bigger>
<x-tad-bigger>{</x-tad-bigger>
<x-tad-bigger>return</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>"document.location='<WEBOBJECT NAME=WOActionURL1></WEBOBJECT>';"</x-tad-bigger><x-tad-bigger>;</x-tad-bigger>
<x-tad-bigger>}</x-tad-bigger>
<x-tad-bigger>WOActionURL1: WOActionURL {</x-tad-bigger>
<x-tad-bigger>action = editLink;</x-tad-bigger>
<x-tad-bigger>}</x-tad-bigger>
<x-tad-bigger>and setting onClick to that but that doesn't replace </x-tad-bigger><x-tad-bigger>WOActionURL1 </x-tad-bigger><x-tad-bigger>with the real url.</x-tad-bigger>
<x-tad-bigger>I also tried adding a javascript function using the </x-tad-bigger><x-tad-bigger>WOActionURL1 </x-tad-bigger><x-tad-bigger>which calls editLink() okay but it then has no idea of where the current repeition is up to and I get aItem = null;</x-tad-bigger>
<x-tad-bigger>I have got it to work using a DA but would like a more light weight solution that can be easily reused.</x-tad-bigger>
-------
Dave _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
http://www.freeiPods.com/?r=21419063
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden