[prev in list] [next in list] [prev in thread] [next in thread]
List: tapestry-user
Subject: RE: Forms w/o Vist object?
From: "James Carroll" <jim () microbrightfield ! com>
Date: 2003-09-26 19:46:37
[Download RAW message or body]
Thanks Julio, It's working _beautifully_ I appreciate your time! I
just can't beleive there's so little code to move around.
-Jim
> -----Original Message-----
> From: Julio C. Rivera [mailto:juceri@ya.com]
> Sent: Friday, September 26, 2003 2:41 PM
> To: Tapestry users
> Subject: RE: Forms w/o Vist object?
>
>
> Well, there are two ways for use "properties" in tapestry:
>
> 1. You can to manage it by hand. This what you have done (declaring a
> private variable, writting get/set methods,...). You have to
> reset the
> property at the end of every requestCycle to a its initial
> values (remeber
> that after every request cycle the page goes back to the pool
> and can by
> reused by another user).
>
> 2. You can declare the property using
> "property-specification" and let to
> tapestry manages it. This is the easier way (and the best).
> If you do so,
> when you need to access to the property value from your java
> code, you have
> to declare your class as "abstract" and declare get and/or
> set methods
> "abstract". In your example:
>
> public **abstract** class RMAEdit extends BasePage
> public **abstract** RMA getCurrentRMA();
>
> public void rmaFormListener(IRequestCycle cycle)
> {
> logger.info("RMA submitted is: " + ****getCurrentRMA(
> )****); // HERE YOU ACCESS TO THE PROPERTY
> }
> }
>
> At runtime, Tapestry will create a subclass that implements
> the abstract
> methos properly.
>
> I hope this answer your questions.
>
> Julio.
>
> At 14:16 26/09/2003 -0400, you wrote:
>
> >Hi Julio!
> >
> >I had it working for a minute by getting rid of all the abstract
> >declarations:
> >----------------
> > public class RMAEdit extends BasePage
> > {
> > static Logger logger = Logger.getLogger("tt.RMAs");
> >
> > private RMA currentRMA = new RMA();
> > public RMA getCurrentRMA() { return currentRMA; }
> >----------------
> >
> >But now I'm trying it your way. My only question is how
> >do I get the page property inside my listener?
> >
> >I've Tried:
> >-----------------------
> > public void rmaFormListener(IRequestCycle cycle)
> > {
> > logger.info("RMA submitted is: " +
> >(RMA)getProperty(currentRMA));
> > }
> >-----------------------
> >
> >But get the compile-time error:
> > [javac]
> >C:\jimc\mbfdb\Jetty-4.2.12\webapps\tt\src\tt\RMAEdit.java:30: getPro
> >perty(java.lang.String) in
> org.apache.tapestry.AbstractComponent cannot
> >be appli
> >ed to (tt.data.RMA)
> >
> >Honestly I know this is a dumb question, but I've searched the
> >tutorials, and the nemesisIT
> >and am just not self-sufficient as far as finding these things yet.
> >(Most of the
> >examples use the Visit object)
> >
> >
> >Thanks!
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Julio C. Rivera [mailto:juceri@ya.com]
> > > Sent: Friday, September 26, 2003 1:53 PM
> > > To: Tapestry users
> > > Subject: RE: Forms w/o Vist object?
> > >
> > >
> > >
> > > You have to declare currentRMA as a property (and let to
> > > tapestry manages
> > > it lifecycle) :
> > >
> > > RMAEdit.page -------------------------------------
> > > ...
> > > <page-specification class="tt.RMAEdit">
> > > <!-- ADD FROM HERE -->
> > > <property-specification name="currentRMA"
> type="yourpackage.RMA"
> > > persistent="no" initial-value="new yourpackage.RMA()" />
> > > <!-- TO HERE -->
> > > .....
> > > </page-specification>
> > >
> > > RMAEdit.java -------------------------------------------------
> > >
> > > public abstract class RMAEdit extends BasePage
> > > {
> > > static Logger logger = Logger.getLogger("tt.RMAs");
> > >
> > > /* REMOVE THIS!!!!!
> > > private RMA currentRMA;
> > > */
> > >
> > > public abstract RMA getCurrentRMA();
> > >
> > > public void rmaFormListener(IRequestCycle cycle)
> > > {
> > > logger.info("RMA submitted is: " + getCurrentRMA( ));
> > > }
> > > ...
> > > }
> > >
> > >
> > > I Hope this helps.
> > > Julio.
> > >
> > >
> > >
> > >
> > >
> > >
> > > At 13:11 26/09/2003 -0400, you wrote:
> > >
> > > >Thanks Tsvetelin and Jimi!
> > > >
> > > >I'm really liking how this is coming together, but it's
> not working
> > > >yet. My Form is for an RMAEdit page, so I have RMAEdit.html,
> > > >RMAEdit.page,
> > > >and RMAEdit.java, and a simple bean called RMA. Here's the
> > > error, and
> > > >the
> > > >code.
> > > >
> > > >I have a currentRMA bean on my RMAEdit page, and I'm
> trying to map my
> > > >form fields directly into it.
> > > >
> > > >Anyone see what I'm doing wrong? Thanks!
> > > >
> > > >RMAEdit.html -------------------------------------
> > > >
> > > ><SPAN jwcid="border@Border" pageTitle="MBF Return Merchandise
> > > >Authorizations">
> > > > <A jwcid="@PageLink" page="Home">go home</A>
> > > >
> > > ><BR>
> > > > <form jwcid="@Form"
> listener="ognl:listeners.rmaFormListener" >
> > > > Customer Name: <input jwcid="customerName" type="text"/>
> > > > <BR>
> > > > Item: <input jwcid="item" type="text"/>
> > > > <BR>
> > > > Received From Customer on: <input
> > > jwcid="receivedFromCustomer"
> > > >type="text" format="MMM dd, yyyy"/> (Month DD, YYYY)
> > > > <BR>
> > > > Returned To Customer on: <input
> jwcid="returnedToCustomer"
> > > >type="text" format="MMM dd, yyyy"/> (Month DD, YYYY)
> > > > <BR>
> > > > <input type="submit" value="Submit"/>
> > > > </form>
> > > ><BR>
> > > > <span jwcid="@contrib:InspectorButton"/>
> > > ></SPAN>
> > > >
> > > >RMAEdit.page -------------------------------------
> > > >
> > > ><?xml version="1.0" encoding="UTF-8"?>
> > > ><!DOCTYPE page-specification PUBLIC
> > > > "-//Apache Software Foundation//Tapestry
> Specification 3.0//EN"
> > > > "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
> > > >
> > > ><page-specification class="tt.RMAEdit">
> > > >
> > > > <component id="customerName" type="TextField">
> > > > <binding name="value"
> expression="currentRMA.customerName"/>
> > > > </component>
> > > >
> > > > <component id="item" type="TextField">
> > > > <binding name="value" expression="currentRMA.item"/>
> > > > </component>
> > > >
> > > > <component id="receivedFromCustomer" type="DatePicker">
> > > > <binding name="value"
> > > >expression="currentRMA.receivedFromCustomer"/>
> > > > </component>
> > > >
> > > > <component id="returnedToCustomer" type="DatePicker">
> > > > <binding name="value"
> > > >expression="currentRMA.returnedToCustomer"/>
> > > > </component>
> > > >
> > > ></page-specification>
> > > >
> > > >RMAEdit.java -------------------------------------------------
> > > >
> > > >public class RMAEdit extends BasePage
> > > >{
> > > > static Logger logger = Logger.getLogger("tt.RMAs");
> > > >
> > > > private RMA currentRMA;
> > > >
> > > > public abstract RMA getCurrentRMA();
> > > >
> > > > public void rmaFormListener(IRequestCycle cycle)
> > > > {
> > > > logger.info("RMA submitted is: " + currentRMA);
> > > > }
> > > >...
> > > >}
> > > >
> > > >RMA.java
> --------------------------------------------------------
> > > >
> > > >public class RMA
> > > >{
> > > > private long id;
> > > >
> > > > private String customerName;
> > > > private String item;
> > > > private String serialNumber;
> > > > private String mbfRMA;
> > > > private String employeeInitials;
> > > > private Date receivedFromCustomer;
> > > > private String vendorRMA;
> > > > private Date sentToVendor;
> > > > private Date receivedFromVendor;
> > > > private Date returnedToCustomer;
> > > > private String reasonClosed;
> > > > private String notes;
> > > >
> > > > /**
> > > > * Hibernate needs a default constructor
> > > > */
> > > > public RMA()
> > > > {
> > > > // default to receiving from customer today.
> > > > receivedFromCustomer = new Date();
> > > > }
> > > >
> > > > /** The accessor method for this RMA identifier.
> > > > *
> > > > * @hibernate.id generator-class="native"
> > > > */
> > > > public long getId()
> > > > {
> > > > return(id);
> > > > }
> > > >
> > > > public void setId(long lId)
> > > > {
> > > > id = lId;
> > > > }
> > > >
> > > > /**
> > > > * customer name
> > > > *
> > > > * @hibernate.property column="customerName" type="string"
> > > > * @return String
> > > > *
> > > > */
> > > > public String getCustomerName()
> > > > {
> > > > return this.customerName;
> > > > }
> > > >
> > > > /**
> > > > * @param string
> > > > */
> > > > public void setCustomerName(String customerName)
> > > > {
> > > > this.customerName = customerName;
> > > > }
> > > >
> > > >...
> > > >--------------------------------
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: tsvetelin [mailto:tsvetelin.saykov@rushmore-digital.com]
> > > > > Sent: Friday, September 26, 2003 10:55 AM
> > > > > To: Tapestry users
> > > > > Subject: RE: Forms w/o Vist object?
> > > > >
> > > > >
> > > > > Hi James,
> > > > >
> > > > > If you would like to reduce the numbers of getters/setters
> > > > > you could use a
> > > > > temporary object (like value object) that will contains all
> > > > > properties of
> > > > > your form. For each form you should define that object. This
> > > > > is some king of
> > > > > data encapsulation. At the other hand you could use this
> > > > > object to store
> > > > > data into database too(ORM - JDO, Hibernate; direct SQL
> > > queries ...)
> > > > >
> > > > > Binding expressition will be:
> > > > >
> > > > > <component id="testInput" type="TextField">
> > > > > <binding name="value"
> > > expression="dataObject.submittedValue" />
> > > > > <static-binding name="displayName">Test
> > > Field</static-binding>
> > > > > </component>
> > > > >
> > > > > If you use a Visit object approach to store temporary data of
> > > > > your forms you
> > > > > will have number getters/setters like number of your forms.
> > > > > At the other
> > > > > hand you could use the Jim's approach either - in this case
> > > > > you will have
> > > > > only one abstract getters/setters pair in you page bean.
> > > > >
> > > > >
> > > > > Tsvetelin.
> > > > >
> > > > > -----Original Message-----
> > > > > From: Jimmi.Dyson@barclayscapital.com
> > > > > [mailto:Jimmi.Dyson@barclayscapital.com]
> > > > > Sent: Friday, September 26, 2003 5:31 PM
> > > > > To: tapestry-user@jakarta.apache.org
> > > > > Subject: RE: Forms w/o Vist object?
> > > > >
> > > > >
> > > > > You don't need to use the Visit object at all if you don't
> > > > > want to. You can
> > > > > specify properties in the page spec and map the fields'
> > > > > values to these. You
> > > > > can then declare abstract getters/setters in your page class
> > > > > and use these
> > > > > in your listener methods. Tapestry extends your page class
> > > > > and fills out the
> > > > > abstract getters and setters. For example:
> > > > >
> > > > > Declare properties in page spec like this:
> > > > >
> > > > > <property-specification name="submittedValue"
> > > > > type="java.lang.String" />
> > > > >
> > > > > Bind the value of your field to this property:
> > > > >
> > > > > <component id="testInput" type="TextField">
> > > > > <binding name="value" expression="submittedValue" />
> > > > > <static-binding name="displayName">Test
> > > Field</static-binding>
> > > > > </component>
> > > > >
> > > > > Now in your page class declare the abstract getter so that
> > > > > you can access
> > > > > the value in your listener method:
> > > > >
> > > > > public abstract String getSubmittedValue();
> > > > >
> > > > > In the listener method, get this value and do what you
> > > want with it:
> > > > >
> > > > > public void submitted(IRequestCycle cycle) {
> > > > > ...
> > > > > String theSubmittedValue = getSubmittedValue();
> > > > > ...
> > > > > }
> > > > >
> > > > > Hope this helps,
> > > > > Jim
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: James Carroll [mailto:jim@microbrightfield.com]
> > > > > Sent: 26 September 2003 15:21
> > > > > To: Tapestry users
> > > > > Subject: RE: Forms w/o Vist object?
> > > > >
> > > > >
> > > > >
> > > > > Thanks Chris, but the Form javadocs still use the parameters
> > > > > stored in the
> > > > > visit object. If an application has one Visit object, and
> > > > > the application
> > > > > has 20 forms (and each form has 3 fields,) do I have to put
> > > > > accessors and
> > > > > mutators for all 60 fields
> > > > > in the single visit object? Do I have to use a naming
> > > > > convention so that
> > > > > different forms with similar fields don't collide
> with each other?
> > > > >
> > > > > I found this link in the archives, where something more
> > > > > direct is happening:
> > > > >
> > > > >
> > > http://www.caddr.com/archives/lists/tapestry-users/2003-8/466.html
> > > > >
> > > > > Dustin does:
> > > > >
> > > > > > <form <Form" at jwcid=">
> > > listener="ognl:listeners.searchAction">
> > > > > > <td><input <TextField" at jwcid="> size class=text
> > > > > > value="ognl:searchText"/></td>
> > > > > > <td><input type=submit class=button label="Go!"></td>
> > > > > > </form>
> > > > > >
> > > > > > I have the following methods in my component class:
> > > > > >
> > > > > > public abstract String getSearchText();
> > > > > >
> > > > > > public void searchAction (IRequestCycle cycle) {
> > > > > > Visit visit = (Visit)getPage().getVisit();
> > > > > > visit.doSearch(getSearchText());
> > > > > > cycle.activate("SearchResults");
> > > > > > }
> > > > >
> > > > > Which looks great, but I don't understand how just an
> > > > > abstract accessor on
> > > > > the page lets the listener see the parameters in the request.
> > > > >
> > > > > -Jim
> > > > >
> > > > >
> > > > > > From: Chris Norris [mailto:CNorris@widen.com]
> > > > > >
> > > > > > I think this is a good example of a form with a listener:
> > > > > >
> > > > > >
> > >
> http://jakarta.apache.org/tapestry/doc/ComponentReference/Form.html
> > > > > >
> > > > > > -chris
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: James Carroll [mailto:jim@microbrightfield.com]
> > > > > > Sent: Friday, September 26, 2003 9:03 AM
> > > > > > To: Tapestry users
> > > > > > Subject: Forms w/o Vist object?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Hi, I'm trying to master Forms, and am getting confused,
> > > > > > If I follow the tutorial at:
> > > > > > http://tapestry-tutorial.cloudnine.net.nz/forms.html
> > > > > >
> > > > > > It binds the fields to propertys of the Visit page i.e.:
> > > > > >
> > > > > > <component id="name" type="TextField">
> > > > > > <binding name="value"
> expression="visit.userName"/>
> > > > > > </component>
> > > > > >
> > > > > > But my understanding is that the Visit object is a place
> > > > > where you put
> > > > > > things that you want to persist throughout the
> user's session.
> > > > > > The equivalent Servlet place would be in the session object.
> > > > > > In the petshop
> > > > > > example, they just keep things like the shopping cart
> > > in the Visit
> > > > > > object which makes sense to me.
> > > > > >
> > > > > > What I would like is to have the form handled by something
> > > > > > that is more equivalent to getting the Parameters out of the
> > > > > > request object.
> > > > > >
> > > > > > I think the solution is to declare a listener which is a
> > > > > > single method in my Page object, but I can't find a good
> > > > > > example to work from. Anyone have any favorite examples?
> > > > > >
> > > > > > Thanks,
> > > > > > -Jim
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > >
> ---------------------------------------------------------------------
> > > > > > 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
> > > > > >
> > > > > >
> > > > >
> > > > >
> > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> > > tapestry-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > > tapestry-user-help@jakarta.apache.org
> > > > >
> > > > >
> > > > > --------------------------------------------------------------
> > > > > ----------
> > > > > For more information about Barclays Capital, please
> > > > > visit our web site at http://www.barcap.com.
> > > > >
> > > > >
> > > > > Internet communications are not secure and therefore
> the Barclays
> > > > > Group does not accept legal responsibility for the
> > > contents of this
> > > > > message. Although the Barclays Group operates anti-virus
> > > programmes,
> > > > > it does not accept responsibility for any damage
> > > whatsoever that is
> > > > > caused by viruses being passed. Any views or opinions
> > > presented are
> > > > > solely those of the author and do not necessarily represent
> > > > > those of the
> > > > > Barclays Group. Replies to this email may be monitored by
> > > > > the Barclays
> > > > > Group for operational or business reasons.
> > > > >
> > > > > --------------------------------------------------------------
> > > > > ----------
> > > > >
> > > > >
> > > > >
> > >
> ---------------------------------------------------------------------
> > > > > 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
> > > > >
> > > > >
> > > >
> > >
> >---------------------------------------------------------------------
> > > >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
> > >
> > >
> >
> >---------------------------------------------------------------------
> >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
>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic