Use if else in the zone to choose between Ajax upload and form and always 
return the zone


Sent from my iPhone

On Nov 26, 2011, at 9:08 AM, Greg Pagendam-Turner <[email protected]> wrote:

> Thanks Taha,
> 
> My code allows an ajax upload of an image via jQuery and then allows the user 
> to crop the image.
> 
> I have:
> <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
> xmlns:p="tapestry:parameter"
>        xmlns:j="tapestry-library:jquery">
> <h2>Upload Image</h2>
> <br />
> <!--<input t:type="upload" t:id="file" t:value="file" validate="required" /> 
> <br/>-->
> <t:zone t:id="uploadZone" id="uploadZone">
> <j:ajaxupload t:id="uploadImage"
>                      t:multiple="false"
>                      t:allowedExtensions="[jpg, png, gif]"
>                      t:sizeLimit="1M">
> <noscript>
> <p>JavaScript must be activated!</p>
> </noscript>
> </j:ajaxupload>
> </t:zone>
> 
> <br/>
> 
> <t:block t:id="uploadResult">
> <div>
> <h4>Crop Image</h4>
> 
> <t:form>
> <t:errors />
> <t:if test="message">
> <p>
> <strong>${message}</strong>
> </p>
> </t:if>
> <t:LygCropImage t:id="cropImage" image="prop:getUncroppedImage()">
> 
> </t:LygCropImage>
> <p><t:LygSubmit t:id="submit" value="literal:Crop Image"></t:LygSubmit></p>
> </t:form>
> </div>
> </t:block>
> </t:layout>
> 
> but I get:
> 
> "Form components may not be placed inside other Form components."
> 
> 
> 
> 
> 
> Regards,
> 
> Greg.
> 
> 
> On 26/11/2011 1:34 PM, Taha Hafeez Siddiqi wrote:
>> Hi
>> 
>> Putting Thiago's answer into code
>> 
>> <div t:type='zone' t:id='myFormZone'>
>>    <form t:type='Form' t:zone='myFormZone'>
>>    </form>
>> </div>
>> 
>> @InjectComponent
>> private Zone myFormZone;
>> 
>> @OnEvent(EventConstants.SUBMIT)
>> Object submit(){
>>    return myFormZone.getBody();
>> }
>> 
>> Not sure why you are using a block.
>> 
>> regards
>> Taha
>> 
>> 
>> On Nov 26, 2011, at 8:43 AM, Greg Pagendam-Turner wrote:
>> 
>>> On 26/11/2011 12:21 PM, Thiago H. de Paula Figueiredo wrote:
>>>> On Sat, 26 Nov 2011 00:10:20 -0200, Greg 
>>>> Pagendam-Turner<[email protected]>  wrote:
>>>> 
>>>>> Hi,
>>>> Hi!
>>>> 
>>>>> How do I write code for a page that contains a form which replaces itself 
>>>>> via Ajax once a certain event has occurred?
>>>> The simplest way is to put the form inside a Zone and make the form's zone 
>>>> update point to it. When the form is submitted, return zone.getBody(), 
>>>> where zone is @InjectComponent private Zone zone.
>>>> 
>>> Thanks for the quick response Thiago.
>>> 
>>> It seems I only need one form. I don't need a form for the trigger event.
>>> 
>>> If I put a form in a block and return that block I get:
>>> 
>>> "Form components may not be placed inside other Form components."
>>> 
>>> Even though there is no form in a form as the only form is the one returned 
>>> by the block.
>>> 
>>> 
>>> Regards,
>>> 
>>> Greg
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to