You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ezra Epstein <ee...@prajnait.com> on 2004/02/07 03:39:40 UTC

General Model for PropertySelection

Before I dive in and write my own, I was wondering if there already exists a
generic model for the PropertySelection component.

A generic model would take several parameters, including:
     A Collection (or List) of values (required)
     A key-path/OGNL expression for the Label (required)
     A key-path/OGNL expression for the Value (optional -- null means use
the item's index)
     An optional string that indicates "no selection"

If such a model already exists, I'd rather not duplicate it.

Thanks,

== Ezra E.



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


Re: General Model for PropertySelection

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Yes LookupModel is a sub interface of IPropertySelectionModel. If you 
look at the methods getOptionCount() downwards, they are all 
implementations of IPropertySelectionModel.

-Harish


Ezra Epstein wrote:

>Hi Harish,
>
>     Could you clarify for me.  Is there a relationship between LookupModel
>and IPropertySelectionModel?
>
>== Ezra E.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>

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


problem when doing callback

Posted by Krthekeyan Suryanarayanan <kr...@verchaska.com>.
Hi all,

can u guys help me in working out the following scenerio.

exception
***************
ApplicationRunTime Exception
**************************************
unable to invoke the listener method when it is performing callback ..


.page entries
*****************
    <property-specification name="callback" 
type="org.apache.tapestry.callback.PageCallback" persistent="yes"/>



I have a MyPage which extend BasePage

public abstract PageCallback getCallback();
public abstract void setCallback(PageCallback value);


formSubmit(IRequestCycle cycle)
{
PageCallback pagecallback = getCallback();
 try
    {
  // somecondition
    }catch(Exception e)
{
     pagecallback.performCallback(cycle);
}
}

what could be the solution.

thanks,
krthekeyan.s


Actual error pasted
*********************
org.apache.tapestry.ApplicationRuntimeException
***********************************************************
Unable to invoke method selectToppings on 
com.vtech.research.tapestry.components.demo.checkbox.delegator.SelectedCheckBox$Enhance_35@1909385[SelectedCheckBox]: 
null

java.lang.NullPointerException
***********************************
Stack Trace:
com.vtech.research.tapestry.components.demo.checkbox.delegator.SelectedCheckBox.selectToppings(SelectedCheckBox.java:85) 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
java.lang.reflect.Method.invoke(Method.java:324) 
org.apache.tapestry.listener.ListenerMap.invokeTargetMethod(ListenerMap.java:301) 
org.apache.tapestry.listener.ListenerMap.access$100(ListenerMap.java:87) 
org.apache.tapestry.listener.ListenerMap$SyntheticListener.invoke(ListenerMap.java:141) 
org.apache.tapestry.listener.ListenerMap$SyntheticListener.actionTriggered(ListenerMap.java:146) 
org.apache.tapestry.form.Form.renderComponent(Form.java:457) 
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:256) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417) 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193) 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781) 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549) 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589) 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666) 
java.lang.Thread.run(Thread.java:534) 



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


Re: static-binding ... should it be used?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 7, 2004, at 1:21 AM, Ezra Epstein wrote:
> In a somewhat recent post, Howard mentioned that if he could re-write
> Tapestry today, one change would be to remove static-binding(s).  I'm
> wondering, given that, how would one express the following without 
> using
> one?
>
>   <component id="documentName" type="ValidField">
>     <binding name="value" expression="visit.docName"/>
>     <static-binding name="displayName" value="Document Name"/>
>   </component>

<binding name="displayName" expression="'Document Name'"/>

Although static bindings are fine with me - keeps things clearer, it 
seems.

	Erik



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


RE: static-binding ... should it be used?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
What I meant was to use the same syntax in the page specification as is used in the HTML template.
But its unimportant, since we aren't going to do that!

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://howardlewisship.com


> -----Original Message-----
> From: Ezra Epstein [mailto:eepstein@prajnait.com] 
> Sent: Saturday, February 07, 2004 1:21 AM
> To: Tapestry users
> Subject: static-binding ... should it be used?
> 
> 
> In a somewhat recent post, Howard mentioned that if he could re-write
> Tapestry today, one change would be to remove static-binding(s).  I'm
> wondering, given that, how would one express the following 
> without using
> one?
> 
>   <component id="documentName" type="ValidField">
>     <binding name="value" expression="visit.docName"/>
>     <static-binding name="displayName" value="Document Name"/>
>   </component>
> 
> = Ezra E.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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


static-binding ... should it be used?

Posted by Ezra Epstein <ee...@prajnait.com>.
In a somewhat recent post, Howard mentioned that if he could re-write
Tapestry today, one change would be to remove static-binding(s).  I'm
wondering, given that, how would one express the following without using
one?

  <component id="documentName" type="ValidField">
    <binding name="value" expression="visit.docName"/>
    <static-binding name="displayName" value="Document Name"/>
  </component>

= Ezra E.


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


At what point does a request become single threaded?

Posted by Ezra Epstein <ee...@prajnait.com>.
I remember reading that by the time a page instance is asked to render the
tapestry application will guarantee that the page instance is being accessed
by a single thread.

What I'm wondering is at what point in the request/response loop does this
single-threaded guarantee kick-in.  In particular, does it hold at the time
of the Engine's service() method?

If you are curious about why this question is being asked... We're using
Hibernate for back-end access.  We haven't yet geared up with Spring
Framework (a likely next step for us).  We want to guarantee that a session
(a) exists and (b) is properly closed at the end of the response.  We've put
this logic in the Engine's service method and realize that, given our
one-hibernate-session-per-thread approach, our code depends on the
application servlet guaranteeing single-threadedness.

THanks,

==  Ezra e.


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


RE: General Model for PropertySelection

Posted by Ezra Epstein <ee...@prajnait.com>.
Hi Harish,

     Could you clarify for me.  Is there a relationship between LookupModel
and IPropertySelectionModel?

== Ezra E.


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


Re: General Model for PropertySelection

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Its as simple as this ...

============================ Utils.java ==============================
This can be replaced by org.apache.tapestry.util.prop.OgnlUtils.get()

<snip>
    /**
     * @param root The object, the property of which will be returned.
     * @param expr This is a simple or complex property expression.
     */
    public static Object getDynaValue(Object root, String expr)
    {
        Object value = null;

        try
        {
            value = Ognl.getValue(expr, root);
        }
        catch (OgnlException e)
        {
            throw new ApplicationRuntimeException("Expression error: " + 
expr, e);
        }

        return value;
    }
</snip>

======================== LookupModelImpl.java ==============================
package xyz.lookupImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.hivemind.ApplicationRuntimeException;

import com.agilix.iprotlims.Utils;
import com.agilix.iprotlims.lookup.LookupModel;
import com.agilix.iprotlims.ps.PersistenceService;

/**
 * @author  Harish Krishnaswamy
 * @version $Id: LookupModelImpl.java,v 1.1 2003/12/08 20:51:20 
hkrishnaswamy Exp $
 * @since   1.0
 */
public class LookupModelImpl implements LookupModel, Cloneable
{
    private List _options;
    private String[] _labelProperties;
    private String _valueProperty;

    private List _labels = new ArrayList();
    private List _values = new ArrayList();
    private Map _valueOptions = new HashMap();
   
    private void loadLabel(int index)
    {
        Object obj;
        String label = "";

        for (int i = 0; i < _labelProperties.length; i++)
        {
            if (Utils.isNull(_labelProperties[i]))
                obj = _options.get(index);
            else
                obj = Utils.getDynaValue(_options.get(index), 
_labelProperties[i]);

            label += (i == 0 ? "" : " ") + String.valueOf(obj);
        }

        _labels.add(index, label);
    }
   
    private void loadValue(int index)
    {
        Object obj, optn = _options.get(index);

        if (Utils.isNull(_valueProperty))
            obj = optn;
        else
            obj = Utils.getDynaValue(optn, _valueProperty);
           
        _values.add(index, String.valueOf(obj));
           
        _valueOptions.put(String.valueOf(obj), optn);
    }
   
    private void buildModel()
    {
        for (int i = 0; i < _options.size(); i++)
        {
            loadLabel(i);
            loadValue(i);
        }
    }

    public LookupModelImpl(List list, String[] labelProperty, String 
valueProperty)
    {
        _options = list;
        _labelProperties = labelProperty;
        _valueProperty = valueProperty;
       
        buildModel();
    }

    public LookupModelImpl(List list, String labelProperty, String 
valueProperty)
    {
        this(list, new String[] { labelProperty }, valueProperty);
    }
   
    /**
     * @see com.agilix.iprotlims.lookup.LookupModel#cloneModel()
     */
    public LookupModel cloneModel()
    {
        try
        {
            LookupModelImpl newModel = (LookupModelImpl) clone();

            newModel._options = new ArrayList(_options);
            newModel._labels = new ArrayList(_labels);
            newModel._values = new ArrayList(_values);
       
            return newModel;
        }
        catch (CloneNotSupportedException e)
        {
            throw new ApplicationRuntimeException(e);
        }
    }
   
    /**
     * This method depends on the object already being cloned using 
LookupModelImpl#cloneModel().
     */
    public void addOption0(Object obj)
    {
        _options.add(0, obj);
        _labels.add(0, "");
        _values.add(0, "-1");
    }
   
    public int getOptionCount()
    {
        return _options.size();
    }

    public Object getOption(int index)
    {
        return _options.get(index);
    }

    public String getLabel(int index)
    {
        return (String) _labels.get(index);
    }

    public String getValue(int index)
    {
        return (String) _values.get(index);
    }

    public Object translateValue(String value)
    {
        return _valueOptions.get(value);
    }

}

-Harish


Ezra Epstein wrote:

>Before I dive in and write my own, I was wondering if there already exists a
>generic model for the PropertySelection component.
>
>A generic model would take several parameters, including:
>     A Collection (or List) of values (required)
>     A key-path/OGNL expression for the Label (required)
>     A key-path/OGNL expression for the Value (optional -- null means use
>the item's index)
>     An optional string that indicates "no selection"
>
>If such a model already exists, I'd rather not duplicate it.
>
>Thanks,
>
>== Ezra E.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>

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