You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/01/04 20:27:35 UTC

Server Side Validation with ajax form loop

Hello, I'm using the ajaxformloop component with a value encoder similar to
jumpstarts AjaxFormLoop Tailored version. The component works flawlessly
when there is no server side errors to return, however when server side
errors exist and the form is returned, my main pr object looses all the
ajaxformloop values that haven't yet been committed to the db. 

Is there way for the onValidate method to return my pr object without losing
the lineItem values and without persisting any of the data?

Please see code below. 

            <t:AjaxFormLoop t:id="lineItem" element="ul"
source="pr.lineItems" value="lineItem" addRow="block:addRow" show="show"
encoder="encoderLineItem">
                                <t:Label
for="quanity">QTY</t:Label><t:TextField disabled="roleManager.disabled"
title="Quantity" t:id="quanity" class="number qty"
value="lineItem.quanity"/>
</t:AjaxFormLoop>


   @OnEvent(EventConstants.ACTIVATE)
    void setupRender() {
        if (this.pr == null) {
            this.pr = new PurchaseRequest();
        } 
}

   void onValidateFromPR() throws Exception  {
//errors to return 
form.recordError(message + fieldName);
}

    @CommitAfter
    Object onSuccess() {
        session.saveOrUpdate(pr);
}

   @SuppressWarnings("unchecked")
    public ValueEncoder getEncoderLineItem() {
        return new ValueEncoder<LineItem>() {

            public String toClient(LineItem value) {
                Long id = value.getId();
                return id == null ? NEW_OBJ : id.toString();
            }

            public LineItem toValue(String idAsString) {
                LineItem lineItem = null;
                Long id = null;

                if (!idAsString.equals(NEW_OBJ)) {
                    id = new Long(idAsString);
                }

                // If new obj, return an empty obj.
                if (id == null) {
                    lineItem = new LineItem();

                    if (!request.isXHR()) {
                        pr.getLineItems().add(lineItem);
                    }
                } // Else, return existing obj
                else {
                    lineItem = (LineItem) session.get(LineItem.class, id);
                }

                // AjaxFormLoop will overwrite several fields of the obj
returned.
                // AjaxFormLoop can't handle null obj, so if null we return
a new empty obj.
                lineItem = lineItem == null ? new LineItem() : lineItem;
                lineItem.setPurchaseRequest(pr);

                return lineItem;
            }
        };
    }


Thanks. 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5120576.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop work around

Posted by Geoff Callender <ge...@gmail.com>.
That's good news. Thanks for letting me know.

Geoff

On 18/04/2012, at 2:31 AM, David Canteros wrote:

> I have done a quick test and it works perfectly!
> Thanks Geoff!
> 
> 
> ------------------------------------------------------------------
> David Germán Canteros
> 
> 
> 2012/4/12 Geoff Callender <ge...@gmail.com>
> 
>> Hi all,
>> 
>> I've taken on board all the suggestions and observations here about
>> AjaxFormLoop problems and fixes, and done a complete rewrite of the
>> JumpStart examples. I've put a beta on the demo site. Is every corner case
>> handled now? I sure hope so. See if you can find a hole in it.
>> 
>>       http://jumpstart.doublenegative.com.au/jumpstart/
>> 
>> Cheers,
>> 
>> Geoff
>> 
>> 
>> On 23/03/2012, at 1:57 AM, George Christman wrote:
>> 
>>> Hi David, after some testing I wanted to provide you with some updates
>> based
>>> on some scenarios I ran into.
>>> 
>>> You'll notice in the !request.isHXR condition, I'm checking for a null
>>> lineItem id. This prevents duplicate objects from being added to the
>>> collection.
>>> 
>>>   @SuppressWarnings("unchecked")
>>>   public ValueEncoder getEncoderLineItem() {
>>>       return new ValueEncoder<LineItem>() {
>>>           public String toClient(LineItem value) {
>>>               Long id = value.getId();
>>>               return id == null ? NEW_OBJ : id.toString();
>>>           }
>>> 
>>>           public LineItem toValue(String idAsString) {
>>>               lineItem = null;
>>> 
>>>               if (!idAsString.equals(NEW_OBJ)) {
>>>                   Long id = new Long(idAsString);
>>>                   lineItem = (LineItem) session.get(LineItem.class, id);
>>>               }
>>> 
>>>               // AjaxFormLoop can't handle null obj, so if null we
>> return
>>> a new empty obj.
>>>               lineItem = lineItem == null ? new LineItem() : lineItem;
>>> 
>>>               if (!request.isXHR() && lineItem.getId() == null) {
>>>                   lineItem.setPurchaseRequest(pr);
>>>                   pr.getLineItems().add(lineItem);
>>>               }
>>>               return lineItem;
>>>           }
>>>       };
>>>   }
>>> 
>>> I also found a cleaner way to copy the persisted data to the new session.
>>> 
>>> 
>>>   void onActivate() {
>>>       System.out.println("onActivate " + this.pr);
>>> 
>>>       if (this.pr == null) {
>>>           this.pr = prPersist != null ? prPersist : new
>> PurchaseRequest();
>>>           prPersist = null;
>>>       }
>>> 
>>>   }
>>> 
>>>   Class<?> onActivate(Long prId) {
>>> 
>>>       PurchaseRequest purchaseRequest = prPersist != null ? prPersist :
>>> (PurchaseRequest) session.get(PurchaseRequest.class, prId);
>>>   }
>>> 
>>> If you have any better solutions, please feel free to share.
>>> 
>>> 
>>> --
>>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5586509.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


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


Re: Server Side Validation with ajax form loop work around

Posted by David Canteros <da...@gmail.com>.
I have done a quick test and it works perfectly!
Thanks Geoff!


------------------------------------------------------------------
David Germán Canteros


2012/4/12 Geoff Callender <ge...@gmail.com>

> Hi all,
>
> I've taken on board all the suggestions and observations here about
> AjaxFormLoop problems and fixes, and done a complete rewrite of the
> JumpStart examples. I've put a beta on the demo site. Is every corner case
> handled now? I sure hope so. See if you can find a hole in it.
>
>        http://jumpstart.doublenegative.com.au/jumpstart/
>
> Cheers,
>
> Geoff
>
>
> On 23/03/2012, at 1:57 AM, George Christman wrote:
>
> > Hi David, after some testing I wanted to provide you with some updates
> based
> > on some scenarios I ran into.
> >
> > You'll notice in the !request.isHXR condition, I'm checking for a null
> > lineItem id. This prevents duplicate objects from being added to the
> > collection.
> >
> >    @SuppressWarnings("unchecked")
> >    public ValueEncoder getEncoderLineItem() {
> >        return new ValueEncoder<LineItem>() {
> >            public String toClient(LineItem value) {
> >                Long id = value.getId();
> >                return id == null ? NEW_OBJ : id.toString();
> >            }
> >
> >            public LineItem toValue(String idAsString) {
> >                lineItem = null;
> >
> >                if (!idAsString.equals(NEW_OBJ)) {
> >                    Long id = new Long(idAsString);
> >                    lineItem = (LineItem) session.get(LineItem.class, id);
> >                }
> >
> >                // AjaxFormLoop can't handle null obj, so if null we
> return
> > a new empty obj.
> >                lineItem = lineItem == null ? new LineItem() : lineItem;
> >
> >                if (!request.isXHR() && lineItem.getId() == null) {
> >                    lineItem.setPurchaseRequest(pr);
> >                    pr.getLineItems().add(lineItem);
> >                }
> >                return lineItem;
> >            }
> >        };
> >    }
> >
> > I also found a cleaner way to copy the persisted data to the new session.
> >
> >
> >    void onActivate() {
> >        System.out.println("onActivate " + this.pr);
> >
> >        if (this.pr == null) {
> >            this.pr = prPersist != null ? prPersist : new
> PurchaseRequest();
> >            prPersist = null;
> >        }
> >
> >    }
> >
> >    Class<?> onActivate(Long prId) {
> >
> >        PurchaseRequest purchaseRequest = prPersist != null ? prPersist :
> > (PurchaseRequest) session.get(PurchaseRequest.class, prId);
> >    }
> >
> > If you have any better solutions, please feel free to share.
> >
> >
> > --
> > View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5586509.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop work around

Posted by Geoff Callender <ge...@gmail.com>.
Hi all,

I've taken on board all the suggestions and observations here about AjaxFormLoop problems and fixes, and done a complete rewrite of the JumpStart examples. I've put a beta on the demo site. Is every corner case handled now? I sure hope so. See if you can find a hole in it.

	http://jumpstart.doublenegative.com.au/jumpstart/

Cheers,

Geoff


On 23/03/2012, at 1:57 AM, George Christman wrote:

> Hi David, after some testing I wanted to provide you with some updates based
> on some scenarios I ran into. 
> 
> You'll notice in the !request.isHXR condition, I'm checking for a null
> lineItem id. This prevents duplicate objects from being added to the
> collection. 
> 
>    @SuppressWarnings("unchecked")
>    public ValueEncoder getEncoderLineItem() {
>        return new ValueEncoder<LineItem>() {
>            public String toClient(LineItem value) {
>                Long id = value.getId();
>                return id == null ? NEW_OBJ : id.toString();
>            }
> 
>            public LineItem toValue(String idAsString) {
>                lineItem = null;
> 
>                if (!idAsString.equals(NEW_OBJ)) {
>                    Long id = new Long(idAsString);
>                    lineItem = (LineItem) session.get(LineItem.class, id);
>                }
> 
>                // AjaxFormLoop can't handle null obj, so if null we return
> a new empty obj.
>                lineItem = lineItem == null ? new LineItem() : lineItem;
> 
>                if (!request.isXHR() && lineItem.getId() == null) {
>                    lineItem.setPurchaseRequest(pr);
>                    pr.getLineItems().add(lineItem);
>                }                
>                return lineItem;
>            }
>        };
>    }
> 
> I also found a cleaner way to copy the persisted data to the new session. 
> 
> 
>    void onActivate() {   
>        System.out.println("onActivate " + this.pr);
> 
>        if (this.pr == null) {
>            this.pr = prPersist != null ? prPersist : new PurchaseRequest();
>            prPersist = null;
>        }
> 
>    }
> 
>    Class<?> onActivate(Long prId) {
> 
>        PurchaseRequest purchaseRequest = prPersist != null ? prPersist :
> (PurchaseRequest) session.get(PurchaseRequest.class, prId);
>    }
> 
> If you have any better solutions, please feel free to share. 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5586509.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


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


Re: Server Side Validation with ajax form loop work around

Posted by George Christman <gc...@cardaddy.com>.
Hi David, after some testing I wanted to provide you with some updates based
on some scenarios I ran into. 

You'll notice in the !request.isHXR condition, I'm checking for a null
lineItem id. This prevents duplicate objects from being added to the
collection. 

    @SuppressWarnings("unchecked")
    public ValueEncoder getEncoderLineItem() {
        return new ValueEncoder<LineItem>() {
            public String toClient(LineItem value) {
                Long id = value.getId();
                return id == null ? NEW_OBJ : id.toString();
            }

            public LineItem toValue(String idAsString) {
                lineItem = null;

                if (!idAsString.equals(NEW_OBJ)) {
                    Long id = new Long(idAsString);
                    lineItem = (LineItem) session.get(LineItem.class, id);
                }
                
                // AjaxFormLoop can't handle null obj, so if null we return
a new empty obj.
                lineItem = lineItem == null ? new LineItem() : lineItem;

                if (!request.isXHR() && lineItem.getId() == null) {
                    lineItem.setPurchaseRequest(pr);
                    pr.getLineItems().add(lineItem);
                }                
                return lineItem;
            }
        };
    }

I also found a cleaner way to copy the persisted data to the new session. 


    void onActivate() {   
        System.out.println("onActivate " + this.pr);

        if (this.pr == null) {
            this.pr = prPersist != null ? prPersist : new PurchaseRequest();
            prPersist = null;
        }

    }

    Class<?> onActivate(Long prId) {
       
        PurchaseRequest purchaseRequest = prPersist != null ? prPersist :
(PurchaseRequest) session.get(PurchaseRequest.class, prId);
    }

If you have any better solutions, please feel free to share. 


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5586509.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop work around

Posted by David Canteros <da...@gmail.com>.
Hi George, finally it worked!  Thank you for the help!

Before I was using the ajaxformloop like as Geoff example, with the tree
arrays XXXtoCreate, XXXToChange and XXXtoDelete and the same encoder.  That
made me think,  probably the problem was caused by Geoff's example and not
by the loop component... I'll make some test next days about it.

Regards!

------------------------------------------------------------------
David Germán Canteros


2012/3/19 George Christman <gc...@cardaddy.com>

> Hi David, I'm using the pr object like so
>
> <div t:type="ajaxFormLoop" t:id="lineItem" source="pr.lineItems"
> value="lineItem" addRow="block:addRow" show="show"
> encoder="encoderLineItem">
>
> It seems to be working perfectly for me. I'm only using the prPersist
> object
> to hold a temporary copy of the current pr at validation. When the page
> reloads with the validation errors, I'm using the prPersist to extract and
> populate my current lineItem objects before immediately disregarding. Be
> sure to implement the value encoder in a similar fashion.
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5578227.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop work around

Posted by George Christman <gc...@cardaddy.com>.
Hi David, I'm using the pr object like so

<div t:type="ajaxFormLoop" t:id="lineItem" source="pr.lineItems"
value="lineItem" addRow="block:addRow" show="show"
encoder="encoderLineItem">

It seems to be working perfectly for me. I'm only using the prPersist object
to hold a temporary copy of the current pr at validation. When the page
reloads with the validation errors, I'm using the prPersist to extract and
populate my current lineItem objects before immediately disregarding. Be
sure to implement the value encoder in a similar fashion.  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5578227.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop work around

Posted by David Canteros <da...@gmail.com>.
Hi George,
 i've done a quick test and it doesnt work on my code, but i will do a full
test by tomorrow. Only one question: which object are you using in the
ajaxformloop (in the tml code)? pr or prPersist?

Regards and thanks!

------------------------------------------------------------------
David Germán Canteros


2012/3/19 George Christman <gc...@cardaddy.com>

> David, I have a working work around, I'm sure it's not the best, but does
> work. See code below.
>
>    @Persist
>    private PurchaseRequest prPersist;
>
>    private PurchaseRequest pr;
>
>    private final String NEW_OBJ = "new";
>
>    void onActivate() {
>        if(prPersist != null) {
>            for(LineItem _lineItem : prPersist.getLineItems()) {
>                if(_lineItem.getId() == null ||
> !pr.getLineItems().contains(_lineItem)) {
>                    _lineItem.setPurchaseRequest(pr);
>                    pr.getLineItems().add(_lineItem);
>                }
>            }
>        }
>       prPersist = null;
>    }
>
>    void onValidateFromPR() {
>        if (form.getHasErrors()) {
>            prPersist = pr;
>        }
>    }
>
>    //Modified Geoff's value encoder.
>    @SuppressWarnings("unchecked")
>    public ValueEncoder getEncoderLineItem() {
>        return new ValueEncoder<LineItem>() {
>
>            public String toClient(LineItem value) {
>                Long id = value.getId();
>                return id == null ? NEW_OBJ : id.toString();
>            }
>
>            public LineItem toValue(String idAsString) {
>                LineItem lineItem = null;
>
>                if (!idAsString.equals(NEW_OBJ)) {
>                    Long id = new Long(idAsString);
>                    lineItem = (LineItem) session.get(LineItem.class, id);
>                }
>
>                // AjaxFormLoop can't handle null obj, so if null we return
> a new empty obj.
>                lineItem = lineItem == null ? new LineItem() : lineItem;
>
>                if (!request.isXHR()) {
>                    lineItem.setPurchaseRequest(pr);
>                    pr.getLineItems().add(lineItem);
>                }
>
>                return lineItem;
>            }
>        };
>    }
>
> Hope this helps.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5577886.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop work around

Posted by George Christman <gc...@cardaddy.com>.
David, I have a working work around, I'm sure it's not the best, but does
work. See code below. 

    @Persist
    private PurchaseRequest prPersist;

    private PurchaseRequest pr;

    private final String NEW_OBJ = "new";

    void onActivate() {
        if(prPersist != null) {
            for(LineItem _lineItem : prPersist.getLineItems()) {
                if(_lineItem.getId() == null ||
!pr.getLineItems().contains(_lineItem)) {
                    _lineItem.setPurchaseRequest(pr);
                    pr.getLineItems().add(_lineItem);
                }
            }
        }
       prPersist = null;
    }

    void onValidateFromPR() {
        if (form.getHasErrors()) {
            prPersist = pr;            
        }
    }

    //Modified Geoff's value encoder. 
    @SuppressWarnings("unchecked")
    public ValueEncoder getEncoderLineItem() {
        return new ValueEncoder<LineItem>() {

            public String toClient(LineItem value) {
                Long id = value.getId();
                return id == null ? NEW_OBJ : id.toString();
            }

            public LineItem toValue(String idAsString) {
                LineItem lineItem = null;

                if (!idAsString.equals(NEW_OBJ)) {
                    Long id = new Long(idAsString);
                    lineItem = (LineItem) session.get(LineItem.class, id);
                }

                // AjaxFormLoop can't handle null obj, so if null we return
a new empty obj.
                lineItem = lineItem == null ? new LineItem() : lineItem;

                if (!request.isXHR()) {
                    lineItem.setPurchaseRequest(pr);
                    pr.getLineItems().add(lineItem);
                }
                
                return lineItem;
            }
        };
    }

Hope this helps. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5577886.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
As a temporary fix, I was looking at doing something like this. 

private PurcahaseRequest pr;

@Persist
private PurchaseRequest prPersist;

Class<?> onActivate(PurchaseRequest pr) {
    this.pr = pr;
}

void onActivate() {
        if (this.pr == null) {
            this.pr = new PurchaseRequest();
       }

        if(prPersist != null) {
            this.pr = prPersist;
            prPersist = null;
        }
}

    Object onPassivate() {
        Object value = null;
        if (this.pr != null) {
            value = this.pr.getId();
        }
        return value;
    }

void onValidateFromPR() {
        if (form.getHasErrors()) {
            prPersist = pr;
        }
}

hover, I get the following exception when a pr is reloaded from the
database. When it's a new pr and does not have any query parameters,
everything works perfectly.  

Render queue error in SetupRender[Purchase_Request:lineitemfunding]: failed
to lazily initialize a collection of role:
org.mydomain.eprs.entities.LineItem.lineItemFundings, no session or session
was closed

When I tried using eager fetch for lineItemFundings, the exception just
popped up with another table which gave me yet another exception stating the
other table couldn't be eager fetched.

Does anybody know how to update a session object with data from a persisted
object without getting the hibernate exception? Thanks.  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5571353.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
Hi David, I created a jira issue related to this bug. 

https://issues.apache.org/jira/browse/TAP5-1875

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5565297.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
Sure, not a problem. I'll file a bug in the morning.


On Thu, Mar 8, 2012 at 2:58 PM, David Canteros [via Tapestry] <
ml-node+s1045711n5548672h69@n5.nabble.com> wrote:

> Could you please do it? My english is not good  (my natural language is
> spanish) and you already have the code with the issue.
> Tell me if you can't.
> Thanks!
>
> David
>
>
>
>
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2012/3/6 George Christman <[hidden email]<http://user/SendEmail.jtp?type=node&node=5548672&i=0>>
>
>
> > Sounds good to me. Do you want to file the jira issue, or would you like
> me
> > to?
> >
> > --
> > View this message in context:
> >
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5540927.html
>
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5548672&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5548672&i=2>
> >
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5548672.html
>  To unsubscribe from Server Side Validation with ajax form loop, click
> here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5120576&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTEyMDU3NnwxNjMyOTYxMjA3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5548686.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Server Side Validation with ajax form loop

Posted by David Canteros <da...@gmail.com>.
Could you please do it? My english is not good  (my natural language is
spanish) and you already have the code with the issue.
Tell me if you can't.
Thanks!

David





------------------------------------------------------------------
David Germán Canteros


2012/3/6 George Christman <gc...@cardaddy.com>

> Sounds good to me. Do you want to file the jira issue, or would you like me
> to?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5540927.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
Sounds good to me. Do you want to file the jira issue, or would you like me
to?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5540927.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by David Canteros <da...@gmail.com>.
Hi George, I still have the problem. I don't understand the underlying code
of the frameworks so i can't find the code that is working wrong, so the
clientside validation is the only way to "solve" it.
We would file a JIRA to get help (i dont saw any similar issue registered
), what do you think?



------------------------------------------------------------------
David Germán Canteros


2012/2/15 George Christman <gc...@cardaddy.com>

> David have you figured out how to get around this issue? I'm using
> clientside
> validation to over come it for the short term, but it would be nice to get
> server side working properly.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5487493.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
David have you figured out how to get around this issue? I'm using clientside
validation to over come it for the short term, but it would be nice to get
server side working properly.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5487493.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by David Canteros <da...@gmail.com>.
I have the same problem with AjaxFormLoop, the values typed on new added
row are lost when server side validations record any error on the form.



------------------------------------------------------------------
David Germán Canteros


2012/2/2 George Christman <gc...@cardaddy.com>

> Hi Geoff, just curious if you ever had a chance to look at this issue
> again?
> Thanks
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5451139.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
Hi Geoff, just curious if you ever had a chance to look at this issue again?
Thanks

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5451139.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by George Christman <gc...@cardaddy.com>.
Hi Geoff, Implemented your suggestion with the same set of results. My pr
object seems to be returned null resulting in the loss of data.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5125845.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Server Side Validation with ajax form loop

Posted by Geoff Callender <ge...@gmail.com>.
Hi George,

I've recreated the problem, but I can't spend more time on it until next week. In the meantime, this may solve all or part of it:

- Add a zone around the form.
- Add the zone parameter to the form.
- Modify the OnValidateFromYourForm method to return an Object.
- Change the final return in OnValidateFromYourForm to return null.
- Change all the other returns in OnValidateFromYourForm to return the zone.getBody().

eg. 

	<div style="margin: 20px;" t:type="zone" t:id="myZone" id="myZone">
		<form t:type="form" t:id="personsedit" t:zone="myZone">



	@InjectComponent
	private Zone wow;


	Object onValidateFromPersonsEdit() {
		:
			return wow.getBody();
		:
		return null;
	}

This will not be enough if the rows have a "remove" action, but otherwise might be OK.

Sorry, I wish I could spend more time on it now.

Regards,

Geoff

On 05/01/2012, at 6:27 AM, George Christman wrote:

> Hello, I'm using the ajaxformloop component with a value encoder similar to
> jumpstarts AjaxFormLoop Tailored version. The component works flawlessly
> when there is no server side errors to return, however when server side
> errors exist and the form is returned, my main pr object looses all the
> ajaxformloop values that haven't yet been committed to the db. 
> 
> Is there way for the onValidate method to return my pr object without losing
> the lineItem values and without persisting any of the data?
> 
> Please see code below. 
> 
>            <t:AjaxFormLoop t:id="lineItem" element="ul"
> source="pr.lineItems" value="lineItem" addRow="block:addRow" show="show"
> encoder="encoderLineItem">
>                                <t:Label
> for="quanity">QTY</t:Label><t:TextField disabled="roleManager.disabled"
> title="Quantity" t:id="quanity" class="number qty"
> value="lineItem.quanity"/>
> </t:AjaxFormLoop>
> 
> 
>   @OnEvent(EventConstants.ACTIVATE)
>    void setupRender() {
>        if (this.pr == null) {
>            this.pr = new PurchaseRequest();
>        } 
> }
> 
>   void onValidateFromPR() throws Exception  {
> //errors to return 
> form.recordError(message + fieldName);
> }
> 
>    @CommitAfter
>    Object onSuccess() {
>        session.saveOrUpdate(pr);
> }
> 
>   @SuppressWarnings("unchecked")
>    public ValueEncoder getEncoderLineItem() {
>        return new ValueEncoder<LineItem>() {
> 
>            public String toClient(LineItem value) {
>                Long id = value.getId();
>                return id == null ? NEW_OBJ : id.toString();
>            }
> 
>            public LineItem toValue(String idAsString) {
>                LineItem lineItem = null;
>                Long id = null;
> 
>                if (!idAsString.equals(NEW_OBJ)) {
>                    id = new Long(idAsString);
>                }
> 
>                // If new obj, return an empty obj.
>                if (id == null) {
>                    lineItem = new LineItem();
> 
>                    if (!request.isXHR()) {
>                        pr.getLineItems().add(lineItem);
>                    }
>                } // Else, return existing obj
>                else {
>                    lineItem = (LineItem) session.get(LineItem.class, id);
>                }
> 
>                // AjaxFormLoop will overwrite several fields of the obj
> returned.
>                // AjaxFormLoop can't handle null obj, so if null we return
> a new empty obj.
>                lineItem = lineItem == null ? new LineItem() : lineItem;
>                lineItem.setPurchaseRequest(pr);
> 
>                return lineItem;
>            }
>        };
>    }
> 
> 
> Thanks. 
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Server-Side-Validation-with-ajax-form-loop-tp5120576p5120576.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>