You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Anil <sa...@cox.net> on 2007/05/16 02:51:47 UTC

Issue with commandLlink and commandButton with popup.

Hi,

I am using Myfaces 1.4, Facelets and Spring Webflow in my project. I have a
problem working with 'commandLink' and 'commandButton'.

In my Page, I have a 'link'(commandLink) and a 'button'(commandButton).

Desired behavior is that when I click on link, it should popup a window and
submit the form and keep target to opened popup. It is working fine.

The following is the code:

Facelet
-------
<input type="submit" jsfc="h:commandLink" tabIndex="1"
action="popupPageAction" target="testWindow" value="Link to My View"
onclick="openWindow();" immediate="true"/>

javascript
-----------
<script language="javascript">
	function openWindow() {
		var url = "";
		window.open(url,'testWindow',"height=650,width=700,top=50,left=200,toolbar
=0,location=0,status=0,menuBar=0,scrollBars=1,resizable=yes");
	}
</script>


for button, when I click on it, it should actually submits my form for
processing and shows the next page in the flow. It is also working fine. The
following is the code

Facelet
-------
<input type="submit" jsfc="h:commandButton" id="continueBtn" action="submit"
value="#{bundle.continue_label}"  tabIndex="2" onclick="onSubmit();return
true;"/>


Issue:

Issue is when my page is rendered, if I click on button it is working as I
expected. But If I click on the link (which would open a popup) and after
that I click on this button, surprisingly it is opening the popup(instead of
processing the form and showing the next page).

Any ideas on why this is happening. I am not really sure whether this is
generic javascript issue or myfaces related issue. Please advice.

Thanks in advance.

Thanks,
Anil.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@facelets.dev.java.net
For additional commands, e-mail: users-help@facelets.dev.java.net


RE: Issue with commandLlink and commandButton with popup.

Posted by Anil <sa...@cox.net>.
Hi All,

I resolved this isssue few days back and forgot to post it in this list.

The solution is I was using "return true" in onlick event of button which is
avoiding the the myfaces generated javascript code being called. MyFaces is
generating the javscript code to clear the target and hidden variables
generated for the events. This method did not get called when I used 'return
true' in commandButton onclick event.

old code:

<input type="submit" jsfc="h:commandButton" id="continueBtn" action="submit"
value="#{bundle.continue_label}"  tabIndex="2" onclick="onSubmit();return
true;"/>

new code:(just removed 'return true')

<input type="submit" jsfc="h:commandButton" id="continueBtn" action="submit"
value="#{bundle.continue_label}"  tabIndex="2" onclick="onSubmit()"/>

Thanks,
Anil.

-----Original Message-----
From: Anil [mailto:sadinenianil@cox.net]
Sent: Tuesday, May 15, 2007 8:52 PM
To: myfaces user
Subject: Issue with commandLlink and commandButton with popup.


Hi,

I am using Myfaces 1.4, Facelets and Spring Webflow in my project. I have a
problem working with 'commandLink' and 'commandButton'.

In my Page, I have a 'link'(commandLink) and a 'button'(commandButton).

Desired behavior is that when I click on link, it should popup a window and
submit the form and keep target to opened popup. It is working fine.

The following is the code:

Facelet
-------
<input type="submit" jsfc="h:commandLink" tabIndex="1"
action="popupPageAction" target="testWindow" value="Link to My View"
onclick="openWindow();" immediate="true"/>

javascript
-----------
<script language="javascript">
	function openWindow() {
		var url = "";
		window.open(url,'testWindow',"height=650,width=700,top=50,left=200,toolbar
=0,location=0,status=0,menuBar=0,scrollBars=1,resizable=yes");
	}
</script>


for button, when I click on it, it should actually submits my form for
processing and shows the next page in the flow. It is also working fine. The
following is the code

Facelet
-------
<input type="submit" jsfc="h:commandButton" id="continueBtn" action="submit"
value="#{bundle.continue_label}"  tabIndex="2" onclick="onSubmit();return
true;"/>


Issue:

Issue is when my page is rendered, if I click on button it is working as I
expected. But If I click on the link (which would open a popup) and after
that I click on this button, surprisingly it is opening the popup(instead of
processing the form and showing the next page).

Any ideas on why this is happening. I am not really sure whether this is
generic javascript issue or myfaces related issue. Please advice.

Thanks in advance.

Thanks,
Anil.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@facelets.dev.java.net
For additional commands, e-mail: users-help@facelets.dev.java.net