[weld-commits] Weld SVN: r5640 - in core/trunk: impl/src/main/java/org/jboss/weld/manager and 2 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Wed Jan 27 12:02:07 EST 2010
Author: pete.muir at jboss.org
Date: 2010-01-27 12:02:07 -0500 (Wed, 27 Jan 2010)
New Revision: 5640
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/Employee.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/SaveAction.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/home.xhtml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
Log:
WELD-404
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2010-01-27 14:06:01 UTC (rev 5639)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2010-01-27 17:02:07 UTC (rev 5640)
@@ -80,7 +80,7 @@
return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
}
}
- return beanManager.getReference(getDeclaringBean(), Object.class, creationalContext);
+ return beanManager.getReference(getDeclaringBean(), creationalContext, true);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-01-27 14:06:01 UTC (rev 5639)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-01-27 17:02:07 UTC (rev 5640)
@@ -765,14 +765,14 @@
}
- public Object getReference(Bean<?> bean, CreationalContext<?> creationalContext, boolean delegate)
+ public Object getReference(Bean<?> bean, CreationalContext<?> creationalContext, boolean noProxy)
{
bean = getMostSpecializedBean(bean);
if (creationalContext instanceof WeldCreationalContext<?>)
{
creationalContext = ((WeldCreationalContext<?>) creationalContext).getCreationalContext(bean);
}
- if (!delegate && isProxyRequired(bean))
+ if (!noProxy && isProxyRequired(bean))
{
if (creationalContext != null || getContext(bean.getScope()).get(bean) != null)
{
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/Employee.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/Employee.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/Employee.java 2010-01-27 17:02:07 UTC (rev 5640)
@@ -0,0 +1,21 @@
+package org.jboss.weld.tests.producer.field.named;
+
+import java.io.Serializable;
+
+
+public class Employee implements Serializable
+{
+
+ private String name;
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/Employee.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java 2010-01-27 14:06:01 UTC (rev 5639)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/NamedProducerTest.java 2010-01-27 17:02:07 UTC (rev 5640)
@@ -33,6 +33,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
/**
* <p>Check what happens when session.invalidate() is called.</p>
@@ -41,15 +42,17 @@
*
*/
@Artifact(addCurrentPackage=false)
- at Classes({User.class, NewUserAction.class})
+ at Classes({User.class, NewUserAction.class, Employee.class, SaveAction.class})
@IntegrationTest(runLocally=true)
@Resources({
@Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
@Resource(destination="view.xhtml", source="view.xhtml"),
+ @Resource(destination="home.xhtml", source="home.xhtml"),
@Resource(destination="/WEB-INF/faces-config.xml", source="faces-config.xml")
})
public class NamedProducerTest extends AbstractWeldTest
{
+
@Test(description = "forum post")
public void testNamedProducerWorks() throws Exception
{
@@ -60,6 +63,24 @@
// Check the page rendered ok
assert getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton") != null;
}
+
+ @Test(description = "WELD-404")
+ public void testNamedProducerFieldLoosesValues() throws Exception
+ {
+ WebClient client = new WebClient();
+
+ HtmlPage page = client.getPage(getPath("/home.jsf"));
+ // Check the page rendered ok
+ HtmlSubmitInput saveButton = getFirstMatchingElement(page, HtmlSubmitInput.class, "saveButton");
+ HtmlTextInput employeeFieldName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeFieldName");
+ HtmlTextInput employeeMethodName = getFirstMatchingElement(page, HtmlTextInput.class, "employeeMethodName");
+ assert employeeFieldName != null;
+ assert employeeMethodName != null;
+ assert saveButton != null;
+ employeeFieldName.setValueAttribute("Pete");
+ employeeMethodName.setValueAttribute("Gavin");
+ saveButton.click();
+ }
protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
{
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/SaveAction.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/SaveAction.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/SaveAction.java 2010-01-27 17:02:07 UTC (rev 5640)
@@ -0,0 +1,46 @@
+package org.jboss.weld.tests.producer.field.named;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+ at Named("save")
+ at SessionScoped
+public class SaveAction implements Serializable
+{
+
+ @Produces
+ @Named
+ private Employee employeeField = new Employee();
+
+ private Employee employeeMethod = new Employee();
+
+ private boolean executeCalled;
+
+ @Produces
+ @Named
+ public Employee getEmployeeMethod()
+ {
+ return employeeMethod;
+ }
+
+ public SaveAction()
+ {
+ }
+
+ public String execute()
+ {
+ assert employeeMethod.getName().equals("Gavin");
+ assert employeeField.getName().equals("Pete");
+ this.executeCalled = true;
+ return "/home?faces-redirect=true";
+ }
+
+ public boolean isExecuteCalled()
+ {
+ return executeCalled;
+ }
+
+}
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/field/named/SaveAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/home.xhtml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/home.xhtml (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/home.xhtml 2010-01-27 17:02:07 UTC (rev 5640)
@@ -0,0 +1,19 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <h:head>
+ <title>New Employee</title>
+ </h:head>
+ <h:body>
+ <ui:debug hotkey="d"/>
+ <h:form>
+ <h:messages/>
+ <h:outputLabel value="Name:"/>
+ <h:inputText value="#{employeeField.name}" id="employeeFieldName" />
+ <h:inputText value="#{employeeMethod.name}" id="employeeMethodName" />
+ <h:commandButton action="#{save.execute}" value="Save!" id="saveButton"/>
+ </h:form>
+ </h:body>
+</html>
Property changes on: core/trunk/tests/src/test/resources/org/jboss/weld/tests/producer/field/named/home.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the weld-commits
mailing list