Thanks Matthias, the link you've listed does explain why I am not
setting a value before the onclick method is called.  Unfortunately,
although that explains why I cannot update a backing value via a binding
method before opening a new window, I still am at a loss as to how I can
in fact open a new window that is passed the current value of my
datatable row.

**Does anyone have an example where they generate a popup window and
pass a value for use by the new window?  I do not understand how a
managed bean might be instantiated if I am submitting a form via
javascript, as explained below.  Ideally, I'd like to simply have a
commandLink in my dataTable that I can use to open the new window, and
bind a value before the page in that window is actually executed.

I _have_ tried one thing that is similar a hack used for getting the
apache display taglib to work with commandLinks: In addition to
surrounding my JSF datatable with a form tag, I've included in that form
tag a standalone commandLink.  I then call a javascript method from the
datatable which sets the _link_hidden_ value of the form to the page I'd
like to open; I also set a dummy param value (I called it "id") like so:


<h:form id="myMainForm">

<t:dataTable value="#{pageFlow.dataList}" var="dbRow"> 
... Some table columns  ...
 <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}">
     </h:commandLink>
   </h:form>
 </t:column>
... More columns ...

 <t:commandLink action="goViewNewPage" id="viewNewPageLink"
   <f:param name="id" value="" />
 </t:commandLink>

</h:form>


<script type="text/javascript">
function myJavaScript(cellValue){
  var f = document.forms['myMainForm'];
 
f.elemnts['myMainForm:_link_hidden_'].value='myMainForm:viewNewPageLink'
;
  f.elements['id'].value=cellValue;
  f.submit();
}




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Matthias Wessendorf
Sent: Tuesday, May 02, 2006 5:55 AM
To: MyFaces Discussion
Subject: Re: Popup New Window with CommandLink onclick attribute

> 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

Reply via email to