PPR does not work for components setup programatically
------------------------------------------------------
Key: TRINIDAD-1006
URL: https://issues.apache.org/jira/browse/TRINIDAD-1006
Project: MyFaces Trinidad
Issue Type: Bug
Components: Components
Affects Versions: 1.0.6-core
Environment: Win2K, Tomahawk 6.0.14, Firefox 2.0.0.12
Reporter: Shane Petroff
Priority: Blocker
I've set up two sets of components which are supposed to be functionally
identical, but they do no behave in the same way. Each pair is composed of a
tr:inputText and a tr:commandButton. The first 'version' is composed into a
standard page, and the second is created programmatically.
The normal declarative version works fine, but the programmatic one does not.
To get to this state, I used the maven create archetype
(http://wiki.apache.org/myfaces/MyFaces_Archetypes_for_Maven) to generate a
hello world app. I dropped back the version numbers for JSF 1.1 (tr v 1.0.6),
then deployed to Tomcat 6.0.14. The return events are 'heard', but the PPR
refresh never succeeds. The files below contain the respective changes to the
hello world app. There are no errors either on the server or js, but the
refresh never happens. I can't decipher the posts associated with the PPR
activity. Any help appreciated, my only fall-back now is to drop Trinidad,
thanks.
Shane
****************HelloWorldBacking.java******************
package org.apache.myfaces.trinidad.blank;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.event.ReturnEvent;
import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
import org.apache.myfaces.trinidad.component.core.nav.CoreCommandButton;
import javax.faces.component.html.HtmlSelectManyListbox;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.model.SelectItem;
import javax.faces.context.FacesContext;
import javax.faces.application.Application;
import java.util.List;
import java.util.ArrayList;
public class HelloWorldBacking
{
private HtmlSelectManyListbox m_CommentList;
public HelloWorldBacking()
{
}
public HtmlSelectManyListbox getCommentList()
{
return m_CommentList;
}
public void setCommentList(HtmlSelectManyListbox commentList )
{
m_CommentList = commentList;
}
public String cancelCommentLibrary()
{
RequestContext.getCurrentInstance().returnFromDialog(null, null);
return null;
}
public String insertFromCommentLibrary()
{
Object returnValue = m_CommentList.getSelectedValues();
RequestContext.getCurrentInstance().returnFromDialog(returnValue, null);
return null;
}
public List getComments()
{
List comments = new ArrayList();
comments.add(new SelectItem("This is a comment"));
comments.add(new SelectItem("qwerty"));
comments.add(new SelectItem("The quick brown fox jumped over the lazy
sleeping dog"));
return comments;
}
///////////////////////////////////////////////
public String getSessionText()
{
FacesContext context = FacesContext.getCurrentInstance();
return (String)
context.getExternalContext().getSessionMap().get("testText");
}
public void setSessionText(final String s)
{
FacesContext context = FacesContext.getCurrentInstance();
context.getExternalContext().getSessionMap().put("testText", s);
}
public String onOpenPage2()
{
return "dialog:openPage2";
}
public void returnedFromPage2( ReturnEvent event)
{
if (event.getReturnValue() != null)
{
Object[] array = (Object[]) event.getReturnValue();
System.out.println( "returned value " + array[0] );
setSessionText(array[0].toString());
}
}
///////////////////////////////////////////////
private HtmlPanelGrid m_MainPanel;
public HtmlPanelGrid getMainPanel()
{
return m_MainPanel;
}
public void setMainPanel(HtmlPanelGrid panel)
{
this.m_MainPanel = panel;
m_MainPanel.setBorder(2);
addContent();
}
private void addContent()
{
Application app = FacesContext.getCurrentInstance().getApplication();
CoreInputText txt = (CoreInputText) app.createComponent(
CoreInputText.COMPONENT_TYPE );
txt.setLabel( "test dynamic" );
txt.setId( "txtID" );
txt.setValueBinding("value",
app.createValueBinding("#{helloWorldBacking.sessionText}"));
txt.setPartialTriggers( new String[] { "btnID" } );
m_MainPanel.getChildren().add(txt);
CoreCommandButton btn = (CoreCommandButton) app.createComponent(
CoreCommandButton.COMPONENT_TYPE );
btn.setText("this does not");
btn.setId( "btnID" );
btn.setAction(app.createMethodBinding("#{helloWorldBacking.onOpenPage2}", null
));
btn.setImmediate(true);
btn.setPartialSubmit(true);
btn.setUseWindow(true);
btn.setWindowWidth(600);
btn.setWindowHeight(300);
btn.setReturnListener(app.createMethodBinding("#{helloWorldBacking.returnedFromPage2}",
new Class[] {
ReturnEvent.class }));
m_MainPanel.getChildren().add(btn);
}
}
****************index.jspx******************
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad" >
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:view>
<tr:document title="PPR Problem">
<tr:form>
<h:panelGrid id="contentPanel" binding="#{helloWorldBacking.mainPanel}"
columns="2" border="1" cellspacing="0" styleClass="panel">
<tr:inputText label="test declarative"
value="#{helloWorldBacking.sessionText}"
partialTriggers="buttonId"/>
<tr:commandButton id="buttonId"
text="this works"
windowWidth="500" windowHeight="500"
partialSubmit="true"
useWindow="true"
action="#{helloWorldBacking.onOpenPage2}"
returnListener="#{helloWorldBacking.returnedFromPage2}"/>
</h:panelGrid>
</tr:form>
</tr:document>
</f:view>
</jsp:root>
****************page2.jspx******************
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:view>
<tr:document title="PPR Problem">
<tr:form>
<tr:panelPage>
<h:outputText value="select something" styleClass="textField"/>
<h:selectManyListbox id="commentLibraryList"
size="3"
binding="#{helloWorldBacking.commentList}"
styleClass="listBox">
<f:selectItems value="#{helloWorldBacking.comments}"/>
</h:selectManyListbox>
<h:commandButton action="#{helloWorldBacking.insertFromCommentLibrary}"
value="insert" styleClass="button"/>
<h:commandButton action="#{helloWorldBacking.cancelCommentLibrary}"
value="cancel" immediate="true" styleClass="button"/>
</tr:panelPage>
</tr:form>
</tr:document>
</f:view>
</jsp:root>
****************faces-config.xml******************
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<application>
<!-- Use the Trinidad RenderKit -->
<default-render-kit-id>
org.apache.myfaces.trinidad.core
</default-render-kit-id>
</application>
<!-- Global preferences object that proxies to others -->
<managed-bean>
<managed-bean-name>helloWorldBacking</managed-bean-name>
<managed-bean-class>
org.apache.myfaces.trinidad.blank.HelloWorldBacking
</managed-bean-class>
<managed-bean-scope>
request
</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>dialog:openPage2</from-outcome>
<to-view-id>/page2.jspx</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.