You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Vangel V. Ajanovski" <aj...@ii.edu.mk> on 2009/09/12 21:25:47 UTC

Tapestry5SelectObject problem with Tomcat - selection is not persisted

Hi,

I have a problem with submitting selection from list box when the 
application is deployed on Tomcat, while it works correctly in Jetty and 
Glassfish.

The selection lists are implemented like in:
http://wiki.apache.org/tapestry/Tapestry5SelectObject

Here is the snippet of code:

<t:form t:id="planSelectForm">
	<t:selectObject t:id="selectPlan" list="planList" value="selectedPlan"
	labelField="literal:title" blankLabel="All" onChange="form.submit();" />
</t:form>

This should refresh a grid that looks like this:

<table t:type="grid" t:source="programs" t:row="programGrid" t:exclude="programId" t:add="literal:delete">

The relevant code behind looks like this:

	@Persist
	@Property
	private Plan selectedPlan;

	public List<Program>  getPrograms() {
		if (selectedPlan == null)
			return ....;
		else
			return ....;
	}

So the form.submit() works and the page refreshes, but it seems like the 
selection has not been persisted and this happens only on Tomcat (6.0.18 
if that matters).

As I mentioned in another message, everything works perfectly in Jetty, 
and I have UTF problems in Glassfish, and this problem in Tomcat.





Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 14 Sep 2009 22:35:32 -0300, Vangel V. Ajanovski <aj...@ii.edu.mk>  
escreveu:

>> Never initialize a Tapestry page field. Use some event handler method
>> to do that.
> This was not the problem because I had several different cases.

It could not be the cause of your specific problem now, but initializing  
fields in their declaration causes one user to see information from other.  
Never do that.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Vangel V. Ajanovski" <aj...@ii.edu.mk>.
On 15.09.2009 03:35, Vangel V. Ajanovski wrote:
> In fact after lot's of debugging it turned out that the problem is 
> again the same as in my other post - bad UTF received from browser 
> after selecting an option.
> The selection boxes were in fact coded with cyrillic character codes 
> which were received incorrectly from the browser.
>
> So once again I had the same problem, although Tapestry is supposed to 
> work entirely in UTF-8, it does not, and depending on server it 
> receives broken input.
>
> I tried setting JAVA_OPTS="-Djavax.servlet.request.encoding=UTF-8" but 
> it doesn't help.
Did I mention I was using Spring and Spring Security? There filters were 
possible messing with UTF-8 requests from browser and I found the 
following solution on several Spring forums, so I mention it also here 
just for reference.

	<filter>
		<filter-name>encodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter
		</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>encodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>




Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Vangel V. Ajanovski" <aj...@ii.edu.mk>.
On 14.09.2009 22:13, Thiago H. de Paula Figueiredo wrote:
> Em Mon, 14 Sep 2009 17:11:31 -0300, Vangel V. Ajanovski 
> <aj...@ii.edu.mk> escreveu:
>>      private List<Plan> planList = new ArrayList<Plan>();
> Never initialize a Tapestry page field. Use some event handler method 
> to do that.
This was not the problem because I had several different cases.

In fact after lot's of debugging it turned out that the problem is again 
the same as in my other post - bad UTF received from browser after 
selecting an option.
The selection boxes were in fact coded with cyrillic character codes 
which were received incorrectly from the browser.

So once again I had the same problem, although Tapestry is supposed to 
work entirely in UTF-8, it does not, and depending on server it receives 
broken input.

I tried setting JAVA_OPTS="-Djavax.servlet.request.encoding=UTF-8" but 
it doesn't help.


Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 14 Sep 2009 17:11:31 -0300, Vangel V. Ajanovski <aj...@ii.edu.mk>  
escreveu:

>      private List<Plan> planList = new ArrayList<Plan>();

Never initialize a Tapestry page field. Use some event handler method to  
do that.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Vangel V. Ajanovski" <aj...@ii.edu.mk>.
On 14.09.2009 14:33, Thiago H. de Paula Figueiredo wrote:
> Em Mon, 14 Sep 2009 00:02:44 -0300, Vangel V. Ajanovski 
> <aj...@ii.edu.mk> escreveu:
>> Then it might be related to how the filter works. The object
>> selectedPlan stays to null after selection and refresh.
>> Anyone any ideas?
> This kind of error is typically cause by lack of proper equals() and 
> hashcode() methods in the class that is put in a colletion.
Tried this and this does not help.
The selectobject component is backed by this:
     @Property
     private List<Plan> planList = new ArrayList<Plan>();

And Plan is an @Entity backed by Hibernate with equals and hashCode 
implemented based on the primary key.


Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 14 Sep 2009 00:02:44 -0300, Vangel V. Ajanovski <aj...@ii.edu.mk>  
escreveu:

> Then it might be related to how the filter works. The object
> selectedPlan stays to null after selection and refresh.
> Anyone any ideas?

This kind of error is typically cause by lack of proper equals() and  
hashcode() methods in the class that is put in a colletion.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Tapestry5SelectObject problem with Tomcat - selection is not persisted

Posted by "Vangel V. Ajanovski" <aj...@ii.edu.mk>.
Just to add, I have the same problem with Jetty setup behind IIS with AJP13.

Then it might be related to how the filter works. The object 
selectedPlan stays to null after selection and refresh.
Anyone any ideas?

On 12.09.2009 21:25, Vangel V. Ajanovski wrote:
> Hi,
>
> I have a problem with submitting selection from list box when the 
> application is deployed on Tomcat, while it works correctly in Jetty 
> and Glassfish.
>
> The selection lists are implemented like in:
> http://wiki.apache.org/tapestry/Tapestry5SelectObject
>
> Here is the snippet of code:
>
> <t:form t:id="planSelectForm">
> <t:selectObject t:id="selectPlan" list="planList" value="selectedPlan"
>     labelField="literal:title" blankLabel="All" 
> onChange="form.submit();" />
> </t:form>
>
> This should refresh a grid that looks like this:
>
> <table t:type="grid" t:source="programs" t:row="programGrid" 
> t:exclude="programId" t:add="literal:delete">
>
> The relevant code behind looks like this:
>
>     @Persist
>     @Property
>     private Plan selectedPlan;
>
>     public List<Program>  getPrograms() {
>         if (selectedPlan == null)
>             return ....;
>         else
>             return ....;
>     }
>
> So the form.submit() works and the page refreshes, but it seems like 
> the selection has not been persisted and this happens only on Tomcat 
> (6.0.18 if that matters).
>
> As I mentioned in another message, everything works perfectly in 
> Jetty, and I have UTF problems in Glassfish, and this problem in Tomcat.
>
>
>
>