You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "F. Da Costa" <da...@xs4all.nl> on 2004/01/02 12:22:56 UTC

Re: Technique to use tapestry windows as popup and technique to call listener form other page (POSSIBLE SOLUTION)

F. Da Costa wrote:
> Hi,
> 
> Browsing throught he list I saw this posting.
> As i am experiencing *exactly* the same same problem as you described I 
> thought would would ask whether you got the issue resolved *and* if you 
> did , whether you would mind sharing your solution?
> 
> I *have* to do this so I figured I might as well ask.
> 
> TIA,
> Fermin DCG
> 
> Konstantin Sharenkov wrote:
> 
>> Keywords: popup link action DirectLink ActionLink PageLink
>>
>> (
>> To tapestry developers:
>>  The followed techniques is need on because I don't find how to realize
>> this behavior by standard tapestry techniques.
>> )
>>
>> Situation:
>> I have a page with list of items  [list.html].
>> When item clicked I want to open popup tapestry window for editing
>> [item.html].
I just solved this with the help of Howard using the IExternalPage
The Item.page would extend the Basepage and implement the IExternalInterface.

Below a couple of snips that I use to get the job done:

.page
<static-binding name="onClick">popupDetails(this.href); return 
false;</static-binding>
This way I make sure the page pops in another window and NOT the current one!

.js:
/**
  * This function does the actual popup
  */
function popupDetails(pop2URL) {
  if (pop2URL) {
   aWindow = window.open(pop2URL, _detailWindowID, _popWindowProperties);
   aWindow.focus();
  }
}

Output .html:
...
<a href="/app?service=external/AveragePriceComposition&amp;sp=SobjectID" 
onClick="top.frmScripts.popupDetails(this.href); return false;">XXX</a>
...

Just thought I would share the resolution of my own efforts with the list.

>>
>> Problem 1. I can't call tapestry window as popup.  Problem 2. If I 
>> call window as popup I want to set current item for the
>> page. I can do it only in event listener. But PageLink is not produce
>> event.
>>
>> (   To Tapestry developers:   I think it is good idea implement popup 
>> properties for  XXXXLink
>> components family
>>   like <a href="#" jwcid="@PageLink" page="Help" popup="true"
>> popupName="helpWindow"> help </a>
>>   or create new component PopupPageLink
>> )
>>
>>
>> Solution.
>> 1.
>> Create component on item page and make it invisible.
>> <span jwcid="selectItem@DirectLink" listener="select"
>> parameters="ognl:0" style="display:none;"/>
>>
>> 2. Use following class
>> public class TapestryHelper
>> {
>>     public static String getDirectLinkRef( IRequestCycle cycle, String
>> page_name, String link_name, Object params )
>>     {
>>         IPage page = cycle.getPage( page_name );
>>         DirectLink component = (DirectLink) page.getComponent( link_name
>> );
>>         component.setProperty( "parameters", params );
>>         ILink link = component.getLink( cycle );
>>         return link.getURL( null, true );
>>     }
>> }
>>
>> 3. Create getter for list.html
>>         public String getPopupUrl()
>>     {
>>         return TapestryHelper.getDirectLinkRef( getRequestCycle(),
>>             "item", "select", new Integer( getCurrentItem().getId() ));
>>     }
>>
>> 4. In list.html use following construction
>> <span jwcid="@Foreach" source="list" value="currentItem">
>>    <a jwcid="@contrib:PopupLink" herf="ognl:popupUrl" ><span
>> jwcid="@Insert" value="ognl:currentItem.name"/> </a>
>> <span>
>>
>> 5. implements  select() listener for item.html
>>        public void selectSurvey( IRequestCycle cycle )
>>     {
>>         Object[] params = cycle.getServiceParameters();
>>         int itemId = ((Integer) params[0]).intValue();
>>
>>         setItemId( itemId );
>>
>>         cycle.activate( this );
>>     }
>>
>> End.
>>
>> Anybody know hot to implement it more correctly.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org