You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kris Rasmussen <kr...@yahoo.com> on 2004/02/19 00:52:14 UTC

inherited-binding

I am trying to create a new PropertySelection component that enables one to sepecify label/value pair in the html template. It works now when the page first renders, however, when a form is submitted it throws an error. I think it might have to do with the inheritted-binding value parameter not working correctly? Here is my code, let me know if anyone has any ideas:
 
 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE component-specification

PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"

"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">

<!-- generated by Spindle, http://spindle.sourceforge.net -->

<component-specification class="com.dreamthis.form.SimplePropertySelection" allow-body="yes" allow-informal-parameters="no">

<description><![CDATA[ Enter a description ]]></description>





<parameter name="value" type="java.lang.Object" required="yes" direction="form"/>

<parameter name="disabled" type="boolean" required="no" direction="in"/>

<parameter name="submitOnChange" type="boolean" required="no" direction="in"/>



<property-specification name="model" type="com.dreamthis.form.SimplePropertySelectionModel" initial-value="new com.dreamthis.form.SimplePropertySelectionModel()"/>



<component id="propertySelection" type="PropertySelection">

<binding name="model" expression="model"/>

<inherited-binding name="value" parameter-name="value"/>

<inherited-binding name="disabled" parameter-name="disabled"/>

<inherited-binding name="submitOnChange" parameter-name="submitOnChange"/>

</component>



</component-specification>
 
 
 

package com.dreamthis.form;

 

import org.apache.tapestry.BaseComponent;

import org.apache.tapestry.IMarkupWriter;

import org.apache.tapestry.IRequestCycle;

public abstract class SimplePropertySelection extends BaseComponent// implements IPropertySelectionModel

{

public static final String SIMPLEPROPERTYSELECTION_ATTRIBUTE = "com.dreamthis.form.SimplePropertySelection";



public abstract SimplePropertySelectionModel getModel();



public void put(String label, String value)

{

getModel().put(label,value);

}



protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)

{

Object objOldValue = cycle.getAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, this);

super.renderComponent(writer, cycle);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, objOldValue);

}

}

 

 

package com.dreamthis.form;

import java.util.Vector;

import org.apache.tapestry.form.IPropertySelectionModel;

public class SimplePropertySelectionModel implements IPropertySelectionModel

{

private Vector values = new Vector();

private Vector labels = new Vector();

public void put(String label, String value)

{

labels.add(label); 

values.add(value);

}

public String getLabel(int i)

{

return (String)labels.get(i);

}

public Object getOption(int i)

{

return (String)values.get(i);

}

public int getOptionCount()

{

return values.size();

}

public String getValue(int i)

{

return (String)values.get(i);

}

public Object translateValue(String value)

{

return value;

}



}

 
 
and finally SimplePropertySelection.html:
 

<span jwcid="@RenderBody"/>

<span jwcid="propertySelection"/>

 

 

There is also a component that retrieves the active property selection when first rendering and puts a key value pair. This is the option component.

 

Thanks,

Kris



---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

Re: inherited-binding

Posted by Kris Rasmussen <kr...@yahoo.com>.
Fixed it. Should have looked at the source code in the first place. Problem was that my component used a form parameter but was not a form so I just extended the PropertySelection class instead and got rid of templates etc.

Kris Rasmussen <kr...@yahoo.com> wrote:Oh and by the way, the error is as follows:

java.lang.ClassCastException 
com.dreamthis.form.SimplePropertySelection$Enhance_27 

Stack Trace: 
org.apache.tapestry.param.AbstractParameterConnector.resetParameter(AbstractParameterConnector.java:189) 
org.apache.tapestry.param.ParameterManager.resetParameters(ParameterManager.java:166) 
org.apache.tapestry.AbstractComponent.cleanupAfterRender(AbstractComponent.java:955) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:886) 
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:657) 
org.apache.tapestry.form.Form.renderComponent(Form.java:396) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:880) 
org.apache.tapestry.form.Form.rewind(Form.java:602) 
org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475) 
org.apache.tapestry.form.Form.trigger(Form.java:616) 
org.apache.tapestry.engine.DirectService.service(DirectService.java:210) 
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:912) 
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238) 
org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:760) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)

Kris Rasmussen wrote:
I am trying to create a new PropertySelection component that enables one to sepecify label/value pair in the html template. It works now when the page first renders, however, when a form is submitted it throws an error. I think it might have to do with the inheritted-binding value parameter not working correctly? Here is my code, let me know if anyone has any ideas:






PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"

"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">














































package com.dreamthis.form;



import org.apache.tapestry.BaseComponent;

import org.apache.tapestry.IMarkupWriter;

import org.apache.tapestry.IRequestCycle;

public abstract class SimplePropertySelection extends BaseComponent// implements IPropertySelectionModel

{

public static final String SIMPLEPROPERTYSELECTION_ATTRIBUTE = "com.dreamthis.form.SimplePropertySelection";



public abstract SimplePropertySelectionModel getModel();



public void put(String label, String value)

{

getModel().put(label,value);

}



protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)

{

Object objOldValue = cycle.getAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, this);

super.renderComponent(writer, cycle);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, objOldValue);

}

}





package com.dreamthis.form;

import java.util.Vector;

import org.apache.tapestry.form.IPropertySelectionModel;

public class SimplePropertySelectionModel implements IPropertySelectionModel

{

private Vector values = new Vector();

private Vector labels = new Vector();

public void put(String label, String value)

{

labels.add(label); 

values.add(value);

}

public String getLabel(int i)

{

return (String)labels.get(i);

}

public Object getOption(int i)

{

return (String)values.get(i);

}

public int getOptionCount()

{

return values.size();

}

public String getValue(int i)

{

return (String)values.get(i);

}

public Object translateValue(String value)

{

return value;

}



}



and finally SimplePropertySelection.html:










There is also a component that retrieves the active property selection when first rendering and puts a key value pair. This is the option component.



Thanks,

Kris



---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.


---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

Re: inherited-binding

Posted by Kris Rasmussen <kr...@yahoo.com>.
Oh and by the way, the error is as follows:
 
java.lang.ClassCastException 
com.dreamthis.form.SimplePropertySelection$Enhance_27 

Stack Trace: 
org.apache.tapestry.param.AbstractParameterConnector.resetParameter(AbstractParameterConnector.java:189) 
org.apache.tapestry.param.ParameterManager.resetParameters(ParameterManager.java:166) 
org.apache.tapestry.AbstractComponent.cleanupAfterRender(AbstractComponent.java:955) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:886) 
org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:657) 
org.apache.tapestry.form.Form.renderComponent(Form.java:396) 
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:880) 
org.apache.tapestry.form.Form.rewind(Form.java:602) 
org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:475) 
org.apache.tapestry.form.Form.trigger(Form.java:616) 
org.apache.tapestry.engine.DirectService.service(DirectService.java:210) 
org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:912) 
org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238) 
org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:760) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)

Kris Rasmussen <kr...@yahoo.com> wrote:
I am trying to create a new PropertySelection component that enables one to sepecify label/value pair in the html template. It works now when the page first renders, however, when a form is submitted it throws an error. I think it might have to do with the inheritted-binding value parameter not working correctly? Here is my code, let me know if anyone has any ideas:






PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"

"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">














































package com.dreamthis.form;



import org.apache.tapestry.BaseComponent;

import org.apache.tapestry.IMarkupWriter;

import org.apache.tapestry.IRequestCycle;

public abstract class SimplePropertySelection extends BaseComponent// implements IPropertySelectionModel

{

public static final String SIMPLEPROPERTYSELECTION_ATTRIBUTE = "com.dreamthis.form.SimplePropertySelection";



public abstract SimplePropertySelectionModel getModel();



public void put(String label, String value)

{

getModel().put(label,value);

}



protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)

{

Object objOldValue = cycle.getAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, this);

super.renderComponent(writer, cycle);

cycle.setAttribute(SIMPLEPROPERTYSELECTION_ATTRIBUTE, objOldValue);

}

}





package com.dreamthis.form;

import java.util.Vector;

import org.apache.tapestry.form.IPropertySelectionModel;

public class SimplePropertySelectionModel implements IPropertySelectionModel

{

private Vector values = new Vector();

private Vector labels = new Vector();

public void put(String label, String value)

{

labels.add(label); 

values.add(value);

}

public String getLabel(int i)

{

return (String)labels.get(i);

}

public Object getOption(int i)

{

return (String)values.get(i);

}

public int getOptionCount()

{

return values.size();

}

public String getValue(int i)

{

return (String)values.get(i);

}

public Object translateValue(String value)

{

return value;

}



}



and finally SimplePropertySelection.html:










There is also a component that retrieves the active property selection when first rendering and puts a key value pair. This is the option component.



Thanks,

Kris



---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.