myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "H. Swaczinna" <swaczi...@wlp-systems.de>
Subject [Tobago] Problem with target attribue (Reminder)
Date Thu, 19 Apr 2007 10:14:30 GMT
Hi,

I want to display the result of an action (a new page) in a new
browser window. So I set the target attribute of tc:link or
tc:button to the window name. This works fine. But when I click another
button or link in the page the action is not executed (the page is
rendered again). I always have to click the button twice.

I think this is a known problem with a known solution. In my code for
the PDF download I included this two lines to avoid this problem:

// Save serialized view or else after clicking on the export button,
// user will have to click TWICE to invoke another action
StateManager stateManager = (StateManager)facesContext.getApplication().getStateManager();
stateManager.saveSerializedView(facesContext);

(Taken from http://swforum.sun.com/jive/thread.jspa?threadID=63566)

Maybe this code should be included in Tobago (or myFaces?) when the
target attribute is set. 

Here's a simple test case for you:

test1.jsp

<f:view>
<tc:page id="testPage1" width="300px" height="200px">
<tc:out value="Page 1"/>
<tc:link label="new window"
target="newWindow"
action="#{controller.newWindowAction}" />
<tc:button label="another action"
action="#{controller.anotherAction}" />
</tc:page>
</f:view>

test2.jsp

<f:view>
<tc:page id="testPage2" width="300px" height="200px">
<tc:out value="Page 2"/>
</tc:page>
</f:view>

faces-config.xml

<navigation-rule>
<from-view-id>/test1.jsp</from-view-id>
<navigation-case>
<from-outcome>newWindow</from-outcome>
<to-view-id>/test2.jsp</to-view-id>
</navigation-case>
</navigation-rule>

Controller.java

public String newWindowAction() {
LOG.debug("newWindowAction");
return "newWindow";
}

public void anotherAction() {
LOG.debug("anotherAction");
}

When you click the "new window" link in test1.jsp a new window is
opened with test2.jsp. But when you click the link again test1.jsp
is displayed in the new window. When you click the "another action"
button after clicking the "new window" link the anotherAction()
is not called. You have to click the button once again.

I'm using myFaces 1.1.5 and Tobago 1.0.11 from yesterday.
I think you should be able to reproduce this behavior.

Regards
Helmut

Mime
View raw message