You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Vitaly Baranovsky (JIRA)" <ta...@jakarta.apache.org> on 2006/08/03 23:40:15 UTC
[jira] Created: (TAPESTRY-1043) "Could not find a strategy instance
for class RubricSelectionModel" when working with PropertySelection
component
"Could not find a strategy instance for class RubricSelectionModel" when working with PropertySelection component
------------------------------------------------------------------------------------------------------------------
Key: TAPESTRY-1043
URL: http://issues.apache.org/jira/browse/TAPESTRY-1043
Project: Tapestry
Issue Type: Bug
Components: Core, Framework, Web
Affects Versions: 4.0.2
Environment: apache-tomcat-5.5.17
Reporter: Vitaly Baranovsky
I've created page with PropertySelection component as written at http://tapestry.apache.org/tapestry4/tapestry/ComponentReference/PropertySelection.html. But it displays error "Could not find a strategy instance for class net.mycompany.portal.news.newslist.RubricSelectionModel".
Same effect is in servlet and in portlet.
My sources:
Edit.html:
<form jwcid="stockQuoteForm">
<input type="text" jwcid="stockId"/>
<select jwcid="rubricSelection"></select>
<input type="submit" value="OK"/>
</form>
Edit.page:
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification
class="net.mycompany.portal.news.newslist.NewsListEditPage">
<component id="stockQuoteForm" type="Form">
<binding name="listener" value="listener:onOk"/>
</component>
<component id="stockId" type="TextField">
<binding name="value" value="ognl:stockId"/>
</component>
<component id="rubricSelection" type="PropertySelection">
<binding name="model" value="ognl:rubricSelectionModel"/>
<binding name="value" value="ognl:currentRubric"/>
</component>
</page-specification>
NewListEditPage.java:
package net.mycompany.portal.news.newslist;
import java.io.IOException;
import javax.portlet.PortletPreferences;
import javax.portlet.ReadOnlyException;
import javax.portlet.ValidatorException;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.html.BasePage;
import net.mycompany.common.CommonRegistry;
public abstract class NewsListEditPage extends BasePage {
@InjectObject("service:tapestry.portlet.PortletRequest")
public abstract javax.portlet.PortletRequest getPortletRequest();
public abstract String getStockId();
public abstract Rubric getCurrentRubric();
public static RubricSelectionModel getRubricSelectionModel(){
return new
RubricSelectionModel(CommonRegistry.getRubricList());
}
public void onOk() {
System.out.println("Listener called. Stock id is: " +
getStockId());
PortletPreferences prefs =
getPortletRequest().getPreferences();
try {
prefs.setValue("DocCount", getStockId());
prefs.setValue("RubricId",
getCurrentRubric().getId().toString());
prefs.store();
} catch (ReadOnlyException e) {
e.printStackTrace();
} catch (ValidatorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
RubricSelectionModel.java:
package net.mycompany.portal.news.newslist;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
public class RubricSelectionModel implements IPropertySelectionModel, Serializable{
private static final long serialVersionUID = 1L;
private List rubricList;
public RubricSelectionModel(List itemList) {
this.rubricList = itemList;
}
public int getOptionCount() { return rubricList.size(); }
public Object getOption(int index) {
return rubricList.get(index);
}
public String getLabel(int index) {
return ((Rubric) rubricList.get(index)).getName();
}
public String getValue(int index) {
return ((Rubric) rubricList.get(index)).getId().toString();
}
public Object translateValue(String value) {
Iterator e = rubricList.iterator();
while(e.hasNext()){
Rubric rubric = (Rubric)e.next();
if(rubric.getId().toString() == value){
return rubric;
}
}
return null;
}
}
Rubric.java:
package net.mycompany.portal.news.newslist;
import java.io.Serializable;
public class Rubric implements Serializable{
private static final long serialVersionUID = 1L;
private Integer id;
private String code;
private String name;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Rubric(Integer id, String code, String name) {
super();
this.id = id;
this.code = code;
this.name = name;
}
}
DBUtils.java:
package net.mycompany.portal.utils;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class DBUtils {
private static DataSource ds;
private static SessionFactory sessionFactory = new
Configuration().configure()
.buildSessionFactory();
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
portlet.xml:
<portlet-app version="1.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<description xml:lang="EN"></description>
<portlet-name>myportlet</portlet-name>
<display-name xml:lang="EN">My Tapestry Portlet</display-name>
<portlet-class>org.apache.tapestry.portlet.ApplicationPortlet</
portlet-class>
<expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>My Tapestry Portlet</title>
<short-title>tapestry-portlet</short-title>
<keywords></keywords>
</portlet-info>
</portlet>
</portlet-app>
web.xml:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>app</display-name>
<servlet>
<servlet-name>ApplicationServlet</servlet-name>
<servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ApplicationServlet</servlet-name>
<url-pattern>/app</url-pattern>
</servlet-mapping>
</web-app>
hivemodule.xml:
doesn't exists
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Resolved: (TAPESTRY-1043) "Could not find a strategy
instance for class RubricSelectionModel" when working with
PropertySelection component
Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/TAPESTRY-1043?page=all ]
Jesse Kuhnert resolved TAPESTRY-1043.
-------------------------------------
Resolution: Invalid
I would try two things:
-) Change the method for getting your model to a non static getter and make the instance you return static.
-) Change the signature of your method to return IPropertySelectionModel instead of your specific type.
> "Could not find a strategy instance for class RubricSelectionModel" when working with PropertySelection component
> -----------------------------------------------------------------------------------------------------------------
>
> Key: TAPESTRY-1043
> URL: http://issues.apache.org/jira/browse/TAPESTRY-1043
> Project: Tapestry
> Issue Type: Bug
> Components: Core, Framework, Web
> Affects Versions: 4.0.2
> Environment: apache-tomcat-5.5.17
> Reporter: Vitaly Baranovsky
>
> I've created page with PropertySelection component as written at http://tapestry.apache.org/tapestry4/tapestry/ComponentReference/PropertySelection.html. But it displays error "Could not find a strategy instance for class net.mycompany.portal.news.newslist.RubricSelectionModel".
> Same effect is in servlet and in portlet.
> My sources:
> Edit.html:
> <form jwcid="stockQuoteForm">
> <input type="text" jwcid="stockId"/>
> <select jwcid="rubricSelection"></select>
> <input type="submit" value="OK"/>
> </form>
> Edit.page:
> <?xml version="1.0"?>
> <!DOCTYPE page-specification PUBLIC
> "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> <page-specification
> class="net.mycompany.portal.news.newslist.NewsListEditPage">
> <component id="stockQuoteForm" type="Form">
> <binding name="listener" value="listener:onOk"/>
> </component>
> <component id="stockId" type="TextField">
> <binding name="value" value="ognl:stockId"/>
> </component>
> <component id="rubricSelection" type="PropertySelection">
> <binding name="model" value="ognl:rubricSelectionModel"/>
> <binding name="value" value="ognl:currentRubric"/>
> </component>
> </page-specification>
> NewListEditPage.java:
> package net.mycompany.portal.news.newslist;
> import java.io.IOException;
> import javax.portlet.PortletPreferences;
> import javax.portlet.ReadOnlyException;
> import javax.portlet.ValidatorException;
> import org.apache.tapestry.annotations.InjectObject;
> import org.apache.tapestry.html.BasePage;
> import net.mycompany.common.CommonRegistry;
> public abstract class NewsListEditPage extends BasePage {
> @InjectObject("service:tapestry.portlet.PortletRequest")
> public abstract javax.portlet.PortletRequest getPortletRequest();
> public abstract String getStockId();
> public abstract Rubric getCurrentRubric();
> public static RubricSelectionModel getRubricSelectionModel(){
> return new
> RubricSelectionModel(CommonRegistry.getRubricList());
> }
> public void onOk() {
> System.out.println("Listener called. Stock id is: " +
> getStockId());
> PortletPreferences prefs =
> getPortletRequest().getPreferences();
> try {
> prefs.setValue("DocCount", getStockId());
> prefs.setValue("RubricId",
> getCurrentRubric().getId().toString());
> prefs.store();
> } catch (ReadOnlyException e) {
> e.printStackTrace();
> } catch (ValidatorException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
> RubricSelectionModel.java:
> package net.mycompany.portal.news.newslist;
> import java.io.Serializable;
> import java.util.Iterator;
> import java.util.List;
> public class RubricSelectionModel implements IPropertySelectionModel, Serializable{
> private static final long serialVersionUID = 1L;
> private List rubricList;
> public RubricSelectionModel(List itemList) {
> this.rubricList = itemList;
> }
> public int getOptionCount() { return rubricList.size(); }
> public Object getOption(int index) {
> return rubricList.get(index);
> }
> public String getLabel(int index) {
> return ((Rubric) rubricList.get(index)).getName();
> }
> public String getValue(int index) {
> return ((Rubric) rubricList.get(index)).getId().toString();
> }
> public Object translateValue(String value) {
> Iterator e = rubricList.iterator();
> while(e.hasNext()){
> Rubric rubric = (Rubric)e.next();
> if(rubric.getId().toString() == value){
> return rubric;
> }
> }
> return null;
> }
> }
> Rubric.java:
> package net.mycompany.portal.news.newslist;
> import java.io.Serializable;
> public class Rubric implements Serializable{
> private static final long serialVersionUID = 1L;
> private Integer id;
> private String code;
> private String name;
> public String getCode() {
> return code;
> }
> public void setCode(String code) {
> this.code = code;
> }
> public Integer getId() {
> return id;
> }
> public void setId(Integer id) {
> this.id = id;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public Rubric(Integer id, String code, String name) {
> super();
> this.id = id;
> this.code = code;
> this.name = name;
> }
> }
> DBUtils.java:
> package net.mycompany.portal.utils;
> import java.sql.Connection;
> import java.sql.DatabaseMetaData;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> import java.sql.Timestamp;
> import java.text.ParseException;
> import java.text.SimpleDateFormat;
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.sql.DataSource;
> import org.hibernate.SessionFactory;
> import org.hibernate.cfg.Configuration;
> public class DBUtils {
> private static DataSource ds;
> private static SessionFactory sessionFactory = new
> Configuration().configure()
> .buildSessionFactory();
> public static SessionFactory getSessionFactory() {
> return sessionFactory;
> }
> }
> portlet.xml:
> <portlet-app version="1.0"
> xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation=
> "http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
> http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
> <portlet>
> <description xml:lang="EN"></description>
> <portlet-name>myportlet</portlet-name>
> <display-name xml:lang="EN">My Tapestry Portlet</display-name>
> <portlet-class>org.apache.tapestry.portlet.ApplicationPortlet</
> portlet-class>
> <expiration-cache>-1</expiration-cache>
> <supports>
> <mime-type>text/html</mime-type>
> <portlet-mode>view</portlet-mode>
> <portlet-mode>help</portlet-mode>
> </supports>
> <supported-locale>en</supported-locale>
> <portlet-info>
> <title>My Tapestry Portlet</title>
> <short-title>tapestry-portlet</short-title>
> <keywords></keywords>
> </portlet-info>
> </portlet>
> </portlet-app>
> web.xml:
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> <display-name>app</display-name>
> <servlet>
> <servlet-name>ApplicationServlet</servlet-name>
> <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>ApplicationServlet</servlet-name>
> <url-pattern>/app</url-pattern>
> </servlet-mapping>
> </web-app>
> hivemodule.xml:
> doesn't exists
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org