You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Will Norris <wi...@willnorris.com> on 2006/08/11 02:59:11 UTC

toggle form display

Hey all, I'm fairly new to Tapestry, having used WebObjects and JSF  
for some time.  I remember seeing a component in some other framework  
that would allow you to have a form that could be toggled to a read- 
only state.  This is not just making the input boxes disabled, but  
rather converting them to be normal text output (so you don't have to  
make an entirely separate page to have someone review their form  
inputs).  So in the Tapestry world, that would mean walking through a  
form and converting TextField components to Insert components (?).   
Is anything like this possible, either as part of Tapestry proper or  
with a third party component?  Am I even clear enough in what I'm  
asking for?

Many thanks,
Will Norris

Re: toggle form display

Posted by Jesse Kuhnert <jk...@gmail.com>.
There is this ,
http://opencomponentry.com:8080/tacos/app?page=ajax%2FInlineEditBoxExample&service=page

or
http://opencomponentry.com:8080/tacos/app?page=ajax%2FEditorExample&service=page

Probably others too but I'm too lazy to look up where they are. (try tassle?
)

On 8/10/06, Will Norris <wi...@willnorris.com> wrote:
>
> Hey all, I'm fairly new to Tapestry, having used WebObjects and JSF
> for some time.  I remember seeing a component in some other framework
> that would allow you to have a form that could be toggled to a read-
> only state.  This is not just making the input boxes disabled, but
> rather converting them to be normal text output (so you don't have to
> make an entirely separate page to have someone review their form
> inputs).  So in the Tapestry world, that would mean walking through a
> form and converting TextField components to Insert components (?).
> Is anything like this possible, either as part of Tapestry proper or
> with a third party component?  Am I even clear enough in what I'm
> asking for?
>
> Many thanks,
> Will Norris
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind.

Re: toggle form display

Posted by Karthik N <ka...@gmail.com>.
you could also try using the disable informal parameter for some HTML input
elements.


something like this in the .html

<input jwcid="SecondOwnFirstName" name="Text1" />

and this in the .page
   <component id="SecondOwnFirstName" type="TextField">
        <binding name="value" value="secOwnFirstName" />
         <binding name="disabled" value="isViewPage" />
    </component>

the isViewPage evaluates to true or false and makes the input  element
disabled.

of course this makes for a server roundtrip.

On 8/17/06, Matt Brock <br...@gmail.com> wrote:
>
>
>
> Will Norris wrote:
> >
> > I remember seeing a component in some other framework
> > that would allow you to have a form that could be toggled to a read-
> > only state.  This is not just making the input boxes disabled, but
> > rather converting them to be normal text output (so you don't have to
> > make an entirely separate page to have someone review their form
> > inputs).
>
> If you want the toggle to be performed without refreshing the client,
> you'll
> have to do it in Javascript.  If, on the other hand, you want a
> conditional
> render on some criteria, there are a couple of ways to do this.  The
> first,
> easiest, but most cumbersome way would be to wrap each form value in an
> @If
> component, where condition=true would render a @TextField, while a
> condition=false would render an Insert.  For example:
>
> <span jwcid="@If" condition="ognl: registeredUser == true">
>    <input jwcid="@TextField" value="ognl: firstName" />
> </span>
> <span jwcid="@Else">
>    <span jwcid="@Insert" value="ognl: firstName" />
> </span>
>
> This would require you to wrap each and every field with an if/else, which
> could be cumbersome on a page with a lot of different fields.  The second
> way to do this would be to create your own TextField component that takes
> whatever condition you're testing for and renders either a form field, or
> just the form value.  It would look something like this:
>
> ToggleField.java:
> ---
> public abstract class ToggleField extends BaseComponent {
>
> /*
> * Note, you can define your parameters here using the @Parameter
> annotation,
> or in the JWC file.
> * I prefer the JWC file.
>
>    @Parameter
>    public abstract Boolean getCondition();
>
>    @Parameter
>    public abstract String getValue();
> */
>
> }
>
> ToggleField.jwc:
> ---
> <?xml version="1.0"?>
> <!DOCTYPE component-specification PUBLIC "-//Apache Software
> Foundation//Tapestry Specification 4.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
>
> <component-specification class="ToggleField" allow-body="yes">
>    <parameter name="condition" required="yes" />
>    <parameter name="value" required="yes" />
> </component-specification>
>
> ToggleField.html:
> ---
> <span jwcid="@If" condition="ognl:condition">
>    <input jwcid="@TextField" value="ognl:value" />
> </span>
> <span jwcid="@Else">
>    <span jwcid="@Insert" value="ognl:value" />
> </span>
>
>
> Usage (inline in an HTML file)
> ---
> <span jwcid="@ToggleField" condition="ognl: registeredUser == true"
> value="ognl: firstName" />
>
> Please forgive any syntactical errors, but that's the basic jist.
> --
> View this message in context:
> http://www.nabble.com/toggle-form-display-tf2088143.html#a5843782
> Sent from the Tapestry - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Thanks, Karthik

Re: toggle form display

Posted by Matt Brock <br...@gmail.com>.

Will Norris wrote:
> 
> I remember seeing a component in some other framework  
> that would allow you to have a form that could be toggled to a read- 
> only state.  This is not just making the input boxes disabled, but  
> rather converting them to be normal text output (so you don't have to  
> make an entirely separate page to have someone review their form  
> inputs).

If you want the toggle to be performed without refreshing the client, you'll
have to do it in Javascript.  If, on the other hand, you want a conditional
render on some criteria, there are a couple of ways to do this.  The first,
easiest, but most cumbersome way would be to wrap each form value in an @If
component, where condition=true would render a @TextField, while a
condition=false would render an Insert.  For example:

<span jwcid="@If" condition="ognl: registeredUser == true">
   <input jwcid="@TextField" value="ognl: firstName" />
</span>
<span jwcid="@Else">
   <span jwcid="@Insert" value="ognl: firstName" />
</span>

This would require you to wrap each and every field with an if/else, which
could be cumbersome on a page with a lot of different fields.  The second
way to do this would be to create your own TextField component that takes
whatever condition you're testing for and renders either a form field, or
just the form value.  It would look something like this:

ToggleField.java:
---
public abstract class ToggleField extends BaseComponent {

/*
* Note, you can define your parameters here using the @Parameter annotation,
or in the JWC file.
* I prefer the JWC file.

   @Parameter
   public abstract Boolean getCondition();

   @Parameter
   public abstract String getValue();
*/

}

ToggleField.jwc:
---
<?xml version="1.0"?>
<!DOCTYPE component-specification PUBLIC "-//Apache Software
Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">

<component-specification class="ToggleField" allow-body="yes">
   <parameter name="condition" required="yes" />
   <parameter name="value" required="yes" />
</component-specification>

ToggleField.html:
---
<span jwcid="@If" condition="ognl:condition">
   <input jwcid="@TextField" value="ognl:value" />
</span>
<span jwcid="@Else">
   <span jwcid="@Insert" value="ognl:value" />
</span>


Usage (inline in an HTML file)
---
<span jwcid="@ToggleField" condition="ognl: registeredUser == true"
value="ognl: firstName" />

Please forgive any syntactical errors, but that's the basic jist.
-- 
View this message in context: http://www.nabble.com/toggle-form-display-tf2088143.html#a5843782
Sent from the Tapestry - User forum at Nabble.com.


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