>From: "Ian.Priest" <[EMAIL PROTECTED]>
>
> Hi,
>
> I think this question is probably about 50% Clay and 50% JSF, so I'll
> start by asking on it this list.
>
> I have a requirement to open a link in a popup window. What I'd like to
> do is have the link as a Clay component and open the popup with the
> result of clicking on the link. I have an actionlink widget:
>
[snippet]
>
>
> Unfortunately I can't see a way of using this type of link to open a
> popup as I'm not sure what url to provide to the window.open() function.
> What I'd like to do in onclick is something like:
>
[snippet]
>
> Can anyone help me out with a solution?
>
I have a couple ideas for you. Both would use the shale view controller for the
event hook instead of the commandLink action method binding. When you use a
shale view controller, you have hooks like the prerender that you could provide
staging logic before the page is rendered.
I have two examples here but I can think of several others. Hopefully this will
give you some ideas.
1) Use the XML config as a primary template.
clay-config.xml
<component jsfid="popupOutputLink1" extends="outputLink" allowBody="false">
<attributes>
<set name="value" value="#" />
<set name="onclick"
value="window.open('@popupHref', 'popup',
'width=500,height=310,scrollbars=yes');" />
</attributes>
<symbols>
<set name="popupHref"/>
<set name="popupLabel"/>
</symbols>
<element renderId="1" jsfid="outputText">
<attributes>
<set name="value" value="@popupLabel" />
</attributes>
</element>
</component>
Html template (home.html)
<a jsfid="popupOutputLink1"
popupHref="viewsource.html?url=WEB-INF/clay-symbols-config.xml"
popupLabel="Test1" href="#">Testing</a><br/>
2) Use an html template in addition to the XML config.
clay-config.xml
<component jsfid="popupOutputLink2" extends="clay" allowBody="false">
<attributes>
<set name="clayJsfid" value="/symbols/popupLink.html" />
</attributes>
<symbols>
<set name="popupHref"/>
<set name="popupLabel"/>
</symbols>
</component>
/symbols/popupLink.html
<a jsfid="outputLink" onclick="window.open('@popupHref', 'popup',
'width=500,height=310,scrollbars=yes');" value="#" href="#">@popupLabel</a>
Html template (home.html)
<a jsfid="popupOutputLink2"
popupHref="viewsource.html?url=WEB-INF/clay-symbols-config.xml"
popupLabel="Test2" href="#">Testing</a><br/>
> Cheers,
> Ian.
>
Gary
>
>
>