You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Romanowski, Tim" <ti...@lmco.com> on 2006/05/01 20:40:12 UTC
Popup New Window with CommandLink onclick attribute
What I would like to do:
I am trying to popup a new window each time a cell in my datatable is
clicked. I fail when attempting to bind (set) a value before the window
is opened; it's the standard master/detail scenario discussed here
several times in the past. The only difference is trying to popup the
window.
Problem:
I am able to popup a window by calling some javascript via the onclick
attribute of the commandLink. I have tried using updateActionListener
to set the value of the current cell's value as is normally used to set
a value befor executing an action. However, because I am using the
onclick attribute to open a new window, the window seems to be rendered
before the updateActionListener actually sets the value. Since the
target attribute doesn't work, I can't do something like
'target="this.form._blank". I am using Apache Beehive for my pageflow
controller, and am attempting to set a value in my controller class; the
idea is that when the popup page is created, the new page's backing bean
can grab the value I previously set in the controller via the
commandLink.
I'm new to webapp development and jumped into JSF/Beehive headfirst, so
my misunderstanding of javascript may be the culprit. Any help would be
greatly appreciated.
Here's a sample of the code:
<t:column>
<f:facet name="header">
<f:verbatim>Header Name</f:verbatim>
</f:facet>
<h:form>
<h:commandLink onclick="myJavaScript(#{dbRow.cellValue})"
value="#dbRow.cellValue}">
<t:updateActionListener
property="#{pageFlow.thisSetsValueInMyController}"
value="#{dbRow.cellValue}" />
</h:commandLink>
</h:form>
</t:column>
Javascript (currently in same page for trying this):
<script type=text/javascript">
Function myJavaScript(cellValue){
popup =
window.open("http://localhost:8080/XYZ/controller/goNewPage.do",
"page name",
"height=300,width=300,resizable=1,toolbar=no,menubar=no");
popup.focus();
}
</script>
TR
Re: Popup New Window with CommandLink onclick attribute
Posted by Matthias Wessendorf <ma...@apache.org>.
> befor executing an action. However, because I am using the onclick
> attribute to open a new window, the window seems to be rendered before the
> updateActionListener actually sets the value. Since the target attribute
this is because you are doing a "non-postback" request
Phase 1 (RESTORE_VIEW) goes directly to Phase 6 (RENDER_RESPONSE)
you may take a look at [1]
-Matthias
[1] Javascript w/ JSF
(http://wiki.apache.org/myfaces/JavascriptWithJavaServerFaces)
> doesn't work, I can't do something like 'target="this.form._blank". I am
> using Apache Beehive for my pageflow controller, and am attempting to set a
> value in my controller class; the idea is that when the popup page is
> created, the new page's backing bean can grab the value I previously set in
> the controller via the commandLink.
>
> I'm new to webapp development and jumped into JSF/Beehive headfirst, so my
> misunderstanding of javascript may be the culprit. Any help would be
> greatly appreciated.
>
> Here's a sample of the code:
>
> <t:column>
> <f:facet name="header">
> <f:verbatim>Header Name</f:verbatim>
> </f:facet>
> <h:form>
> <h:commandLink onclick="myJavaScript(#{dbRow.cellValue})"
> value="#dbRow.cellValue}">
> <t:updateActionListener
> property="#{pageFlow.thisSetsValueInMyController}"
> value="#{dbRow.cellValue}" />
> </h:commandLink>
> </h:form>
> </t:column>
>
> Javascript (currently in same page for trying this):
>
> <script type=text/javascript">
> Function myJavaScript(cellValue){
> popup =
> window.open("http://localhost:8080/XYZ/controller/goNewPage.do",
> "page name",
> "height=300,width=300,resizable=1,toolbar=no,menubar=no");
> popup.focus();
> }
> </script>
>
>
>
> TR
>
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
http://jroller.com/page/mwessendorf
mwessendorf-at-gmail-dot-com