You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Zimowski <zi...@gmail.com> on 2008/03/06 12:49:29 UTC

T5: Weird RadioGroup/Radio ClassCast with Enum

I have a very simple radiogroup backed by the enum (below is grossly
simplified & trimmed version from my project page), running on 5.0.10.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
<title>test</title>
</head>

<body>

	<h3>Web Registrations</h3>

	<t:form t:id="matchForm" t:clientValidation="false">
	<t:errors/>
	<t:radiogroup t:value="matchType" validate="required">
	<input type="radio" t:type="radio" t:value="easyMatch"/>Easy
	<input type="radio" t:type="radio" t:value="customerByIdMatch"/>By Customer ID
	</t:radiogroup>

	<input type="submit" t:type="submit" t:id="submitButton" value="Search"/>
	<input type="submit" t:type="submit" t:id="resetButton" value="Reset"/>

	</t:form>

</body>
</html>

public class Registrations {
	
	@Persist
	private MatchType _matchType;
	
	@Component
	private Form _matchForm;

	
	public MatchType getMatchType() {
		return _matchType;
	}

	public void setMatchType(MatchType aMatchType) {
		_matchType = aMatchType;
	}
	
	public MatchType getEasyMatch() {
		return MatchType.EASY;
	}
	
	public MatchType getCustomerByIdMatch() {
		return MatchType.BY_CUSTOMER_ID;
	}

	@OnEvent(component="matchForm",value="validateForm")
	void validateMatch() {
		if(_matchType == null) {
			_matchForm.recordError("Indicate match type!");
		}
	}
	
	@OnEvent(component="resetButton",value="selected")
	void resetMatchForm() {
		_matchType = null;
		_matchForm.clearErrors();
	}
}

public enum MatchType {

	EASY, BY_CUSTOMER_ID
}


This very simple form works as expected until changes are made to
either the template or a backing java class while jetty is running.
For example, adding some string below <h3>..</h3>:

<h3>Web Registrations</h3>
Some live change to the template while Jetty is running...
<t:form t:id="matchForm" t:clientValidation="false">
....

still works if there is no value assigned to the radiogroup (form
hasn't been submitted). However, if either of the radio buttons has
been submitted, and above change is made Tapestry throws a weird
ClassCastException on the enum as below:

org.apache.tapestry.ioc.internal.util.TapestryException
com.kkamerica.workbench.pages.chweb.regfix.MatchType

java.lang.ClassCastException
com.kkamerica.workbench.pages.chweb.regfix.MatchType

Stack trace
com.kkamerica.workbench.pages.chweb.regfix.View.containingPageDidAttach(View.java)
org.apache.tapestry.internal.structure.ComponentPageElementImpl$2.run(ComponentPageElementImpl.java:71)
org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:874)
org.apache.tapestry.internal.structure.ComponentPageElementImpl.containingPageDidAttach(ComponentPageElementImpl.java:706)
org.apache.tapestry.internal.structure.PageImpl.attached(PageImpl.java:146)
org.apache.tapestry.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:45)
org.apache.tapestry.internal.services.RequestEncodingInitializerImpl.initializeRequestEncoding(RequestEncodingInitializerImpl.java:41)
org.apache.tapestry.services.TapestryModule$39.handle(TapestryModule.java:2071)
org.apache.tapestry.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:131)
org.apache.tapestry.services.TapestryModule$13.service(TapestryModule.java:911)
org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:43)
org.apache.tapestry.services.TapestryModule$3.service(TapestryModule.java:529)
org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:504)
org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:891)
org.apache.tapestry.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:164)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
org.mortbay.jetty.Server.handle(Server.java:285)
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)

This also happens if hot deploy changes are made to a java class, for
instance adding a logger with some debugs would yield the same result.
My work around right now is to restart Jetty, but because of this I'm
loosing the whole benefit of on the fly changes Tapestry offers.

Is there a wrong setup on my part of an unexpected issue I've ran into?

-adam

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Weird RadioGroup/Radio ClassCast with Enum

Posted by Adam Zimowski <zi...@gmail.com>.
Heh... "pages" package is very picky. Enums and other non-page classes
offend Tapestry and that's where exception is comming from. Moving the
enum outside of the pages package makes Tapestry behave properly :)


On Thu, Mar 6, 2008 at 5:53 AM, Adam Zimowski <zi...@gmail.com> wrote:
> Also, igonre the validate="required" in radiogroup - it was a typo.
>  The issue ofcourse still occurrs when validate="required" is removed.
>
>
>
>  On Thu, Mar 6, 2008 at 5:49 AM, Adam Zimowski <zi...@gmail.com> wrote:
>  > I have a very simple radiogroup backed by the enum (below is grossly
>  >  simplified & trimmed version from my project page), running on 5.0.10.
>  >
>  >  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>  >  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>  >  <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>  >  <head>
>  >  <title>test</title>
>  >  </head>
>  >
>  >  <body>
>  >
>  >         <h3>Web Registrations</h3>
>  >
>  >         <t:form t:id="matchForm" t:clientValidation="false">
>  >         <t:errors/>
>  >         <t:radiogroup t:value="matchType" validate="required">
>  >         <input type="radio" t:type="radio" t:value="easyMatch"/>Easy
>  >         <input type="radio" t:type="radio" t:value="customerByIdMatch"/>By Customer ID
>  >         </t:radiogroup>
>  >
>  >         <input type="submit" t:type="submit" t:id="submitButton" value="Search"/>
>  >         <input type="submit" t:type="submit" t:id="resetButton" value="Reset"/>
>  >
>  >         </t:form>
>  >
>  >  </body>
>  >  </html>
>  >
>  >  public class Registrations {
>  >
>  >         @Persist
>  >         private MatchType _matchType;
>  >
>  >         @Component
>  >         private Form _matchForm;
>  >
>  >
>  >         public MatchType getMatchType() {
>  >                 return _matchType;
>  >         }
>  >
>  >         public void setMatchType(MatchType aMatchType) {
>  >                 _matchType = aMatchType;
>  >         }
>  >
>  >         public MatchType getEasyMatch() {
>  >                 return MatchType.EASY;
>  >         }
>  >
>  >         public MatchType getCustomerByIdMatch() {
>  >                 return MatchType.BY_CUSTOMER_ID;
>  >         }
>  >
>  >         @OnEvent(component="matchForm",value="validateForm")
>  >         void validateMatch() {
>  >                 if(_matchType == null) {
>  >                         _matchForm.recordError("Indicate match type!");
>  >                 }
>  >         }
>  >
>  >         @OnEvent(component="resetButton",value="selected")
>  >         void resetMatchForm() {
>  >                 _matchType = null;
>  >                 _matchForm.clearErrors();
>  >         }
>  >  }
>  >
>  >  public enum MatchType {
>  >
>  >         EASY, BY_CUSTOMER_ID
>  >  }
>  >
>  >
>  >  This very simple form works as expected until changes are made to
>  >  either the template or a backing java class while jetty is running.
>  >  For example, adding some string below <h3>..</h3>:
>  >
>  >  <h3>Web Registrations</h3>
>  >  Some live change to the template while Jetty is running...
>  >  <t:form t:id="matchForm" t:clientValidation="false">
>  >  ....
>  >
>  >  still works if there is no value assigned to the radiogroup (form
>  >  hasn't been submitted). However, if either of the radio buttons has
>  >  been submitted, and above change is made Tapestry throws a weird
>  >  ClassCastException on the enum as below:
>  >
>  >  org.apache.tapestry.ioc.internal.util.TapestryException
>  >  com.kkamerica.workbench.pages.chweb.regfix.MatchType
>  >
>  >  java.lang.ClassCastException
>  >  com.kkamerica.workbench.pages.chweb.regfix.MatchType
>  >
>  >  Stack trace
>  >  com.kkamerica.workbench.pages.chweb.regfix.View.containingPageDidAttach(View.java)
>  >  org.apache.tapestry.internal.structure.ComponentPageElementImpl$2.run(ComponentPageElementImpl.java:71)
>  >  org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:874)
>  >  org.apache.tapestry.internal.structure.ComponentPageElementImpl.containingPageDidAttach(ComponentPageElementImpl.java:706)
>  >  org.apache.tapestry.internal.structure.PageImpl.attached(PageImpl.java:146)
>  >  org.apache.tapestry.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:45)
>  >  org.apache.tapestry.internal.services.RequestEncodingInitializerImpl.initializeRequestEncoding(RequestEncodingInitializerImpl.java:41)
>  >  org.apache.tapestry.services.TapestryModule$39.handle(TapestryModule.java:2071)
>  >  org.apache.tapestry.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:131)
>  >  org.apache.tapestry.services.TapestryModule$13.service(TapestryModule.java:911)
>  >  org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:43)
>  >  org.apache.tapestry.services.TapestryModule$3.service(TapestryModule.java:529)
>  >  org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:504)
>  >  org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
>  >  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
>  >  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
>  >  org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
>  >  org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
>  >  org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:891)
>  >  org.apache.tapestry.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
>  >  org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:164)
>  >  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
>  >  org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
>  >  org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
>  >  org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  >  org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
>  >  org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
>  >  org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
>  >  org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>  >  org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>  >  org.mortbay.jetty.Server.handle(Server.java:285)
>  >  org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
>  >  org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
>  >  org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
>  >  org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
>  >  org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
>  >  org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
>  >  org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
>  >
>  >  This also happens if hot deploy changes are made to a java class, for
>  >  instance adding a logger with some debugs would yield the same result.
>  >  My work around right now is to restart Jetty, but because of this I'm
>  >  loosing the whole benefit of on the fly changes Tapestry offers.
>  >
>  >  Is there a wrong setup on my part of an unexpected issue I've ran into?
>  >
>  >  -adam
>  >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Weird RadioGroup/Radio ClassCast with Enum

Posted by Adam Zimowski <zi...@gmail.com>.
Also, igonre the validate="required" in radiogroup - it was a typo.
The issue ofcourse still occurrs when validate="required" is removed.

On Thu, Mar 6, 2008 at 5:49 AM, Adam Zimowski <zi...@gmail.com> wrote:
> I have a very simple radiogroup backed by the enum (below is grossly
>  simplified & trimmed version from my project page), running on 5.0.10.
>
>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>  <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>  <head>
>  <title>test</title>
>  </head>
>
>  <body>
>
>         <h3>Web Registrations</h3>
>
>         <t:form t:id="matchForm" t:clientValidation="false">
>         <t:errors/>
>         <t:radiogroup t:value="matchType" validate="required">
>         <input type="radio" t:type="radio" t:value="easyMatch"/>Easy
>         <input type="radio" t:type="radio" t:value="customerByIdMatch"/>By Customer ID
>         </t:radiogroup>
>
>         <input type="submit" t:type="submit" t:id="submitButton" value="Search"/>
>         <input type="submit" t:type="submit" t:id="resetButton" value="Reset"/>
>
>         </t:form>
>
>  </body>
>  </html>
>
>  public class Registrations {
>
>         @Persist
>         private MatchType _matchType;
>
>         @Component
>         private Form _matchForm;
>
>
>         public MatchType getMatchType() {
>                 return _matchType;
>         }
>
>         public void setMatchType(MatchType aMatchType) {
>                 _matchType = aMatchType;
>         }
>
>         public MatchType getEasyMatch() {
>                 return MatchType.EASY;
>         }
>
>         public MatchType getCustomerByIdMatch() {
>                 return MatchType.BY_CUSTOMER_ID;
>         }
>
>         @OnEvent(component="matchForm",value="validateForm")
>         void validateMatch() {
>                 if(_matchType == null) {
>                         _matchForm.recordError("Indicate match type!");
>                 }
>         }
>
>         @OnEvent(component="resetButton",value="selected")
>         void resetMatchForm() {
>                 _matchType = null;
>                 _matchForm.clearErrors();
>         }
>  }
>
>  public enum MatchType {
>
>         EASY, BY_CUSTOMER_ID
>  }
>
>
>  This very simple form works as expected until changes are made to
>  either the template or a backing java class while jetty is running.
>  For example, adding some string below <h3>..</h3>:
>
>  <h3>Web Registrations</h3>
>  Some live change to the template while Jetty is running...
>  <t:form t:id="matchForm" t:clientValidation="false">
>  ....
>
>  still works if there is no value assigned to the radiogroup (form
>  hasn't been submitted). However, if either of the radio buttons has
>  been submitted, and above change is made Tapestry throws a weird
>  ClassCastException on the enum as below:
>
>  org.apache.tapestry.ioc.internal.util.TapestryException
>  com.kkamerica.workbench.pages.chweb.regfix.MatchType
>
>  java.lang.ClassCastException
>  com.kkamerica.workbench.pages.chweb.regfix.MatchType
>
>  Stack trace
>  com.kkamerica.workbench.pages.chweb.regfix.View.containingPageDidAttach(View.java)
>  org.apache.tapestry.internal.structure.ComponentPageElementImpl$2.run(ComponentPageElementImpl.java:71)
>  org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:874)
>  org.apache.tapestry.internal.structure.ComponentPageElementImpl.containingPageDidAttach(ComponentPageElementImpl.java:706)
>  org.apache.tapestry.internal.structure.PageImpl.attached(PageImpl.java:146)
>  org.apache.tapestry.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:45)
>  org.apache.tapestry.internal.services.RequestEncodingInitializerImpl.initializeRequestEncoding(RequestEncodingInitializerImpl.java:41)
>  org.apache.tapestry.services.TapestryModule$39.handle(TapestryModule.java:2071)
>  org.apache.tapestry.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:131)
>  org.apache.tapestry.services.TapestryModule$13.service(TapestryModule.java:911)
>  org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:43)
>  org.apache.tapestry.services.TapestryModule$3.service(TapestryModule.java:529)
>  org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:504)
>  org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
>  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
>  org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
>  org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
>  org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
>  org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:891)
>  org.apache.tapestry.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
>  org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:164)
>  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1065)
>  org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
>  org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:185)
>  org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>  org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:689)
>  org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:391)
>  org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:146)
>  org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>  org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>  org.mortbay.jetty.Server.handle(Server.java:285)
>  org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:457)
>  org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:765)
>  org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:627)
>  org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
>  org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:357)
>  org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:329)
>  org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)
>
>  This also happens if hot deploy changes are made to a java class, for
>  instance adding a logger with some debugs would yield the same result.
>  My work around right now is to restart Jetty, but because of this I'm
>  loosing the whole benefit of on the fly changes Tapestry offers.
>
>  Is there a wrong setup on my part of an unexpected issue I've ran into?
>
>  -adam
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org