s:convertEntity in h:selectOneMenu produces indexes for option tags only
kwutzke Jul 7, 2011 10:55 AMHello,
I have a rarer case of using a dropdown box for navigation. I want to switch seasons on certain pages, so this is what I use:
<form method="get" enctype="application/x-www-form-urlencoded">
<h:selectOneMenu value="#{seasonHome.id}" id="season" onchange="this.form.submit();">
<s:selectItems value="#{seasonListQuery.resultList}"
var="season"
label="xxxSeason #{season.startYear}"
noSelectionLabel="Select Season"
hideNoSelectionLabel="true" />
<s:convertEntity />
</h:selectOneMenu>
» Competitions
</form>
Note I can't use h:form here, as I need a HTTP GET for this, which h:form doesn't support (see jsftoolbox.com).
seasonListQuery is a simple EntityQuery sub class which returns all current season entities from the DB:
SELECT se FROM Season se
Note the Season entity has implemented equals and hashCode sufficiently.
However, all that happens when the page is rendered is this:
<form method="get" enctype="application/x-www-form-urlencoded"> <select id="season" name="season" size="1" onchange="this.form.submit();"> <option value="0">xxxSeason 2011</option> <option value="1">xxxSeason 2003</option> <option value="2">xxxSeason 2002</option> <option value="3">xxxSeason 2001</option> </select> » Competitions </form>
Whatever I've tried the past 2 days I always end up with the indexes in the option values. The entity converter doesn't even seem to be triggered.
Here's what I get when omitting the s:convertEntity:
<form method="get" enctype="application/x-www-form-urlencoded"> <select id="season" name="season" size="1" onchange="this.form.submit();"> <option value="com.kawoolutions.bbstats.model.Season@37b7a72b[startYear=2011]">xxxSeason 2011</option> <option value="com.kawoolutions.bbstats.model.Season@50a5314[startYear=2003]">xxxSeason 2003</option> <option value="com.kawoolutions.bbstats.model.Season@68d448a1[startYear=2002]">xxxSeason 2002</option> <option value="com.kawoolutions.bbstats.model.Season@48ec77cb[startYear=2001]">xxxSeason 2001</option> </select> » Competitions </form>
What's wrong?
Here's my components.xml:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:ui="http://jboss.com/products/seam/ui"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd
http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.2.xsd
http://jboss.com/products/seam/ui http://jboss.com/products/seam/ui-2.2.xsd">
<persistence:entity-manager-factory name="emf"
persistence-unit-name="MyPersistenceUnit"
auto-create="true" />
<persistence:managed-persistence-context name="em"
entity-manager-factory="#{emf}"
auto-create="true" />
<transaction:entity-transaction entity-manager="#{em}"
auto-create="true" />
<ui:jpa-entity-loader entity-manager="#{em}" />
</components>
I've followed the examples in Seam in Action
on pages 358-359 without success (Seam 2.1 config). Note I'm using Seam 2.2.2 on Tomcat 6.
I really need to get s:convertEntity to work because I have other season-switchable pages which use entities with composite keys, so working around/manually building the select doesn't really help (I already got that).
So why isn't this working? Is it my config? Tomcat? How do I debug this (no exceptions are thrown AFAIK)?
Any help would be highly appreciated
Karsten