You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by manuel aldana <al...@gmx.de> on 2009/04/18 12:38:53 UTC

[bean-edit-form] make a sub-set of parameters visible but not editable

Hi,

I am using the BeanEditor Form for editing users. For that I would like 
to have a "partial" editing form, i.e. I want to protect certain columns 
from being edited.

Example is the id of the object: Once it is created I want to have it 
visible but not editable. Using the @NonVisual flag or exlude parameter 
of BeanEdit-Form component wouldn't do this, it would just remove the 
column from the frontend completely. I had a look at <t:parameter> 
overrides but it does not seem to support a read-only flag.

Generally I would need something more flexible how to tell whether a 
parameter is read-only or editable inside the form. For my current 
problem the read-only vs. editable depends on roles (i.e. different 
roles have different access rights to edit certain fields).

thanks.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by Ulrich Stärk <ul...@spielviel.de>.
Add a <t:parameter> block for the cell you want to have non-editable and 
just output its value. Something along

<t:beaneditform value="foo">
   <t:parameter name="barCell">
     <t:if test="hasEditRights">
       <t:label for="barField" />
       <t:textfield t:id="barField" value="foo.bar" />
       <p:else>
         ${foo.bar}
       </p:else>
     </t:if>
   <t:parameter>
</t:beaneditform>

public boolean isHasEditRights()
{
   return user.inRole(FOO_ROLE) || user.inRole(BAR_ROLE);
}

HTH,

Uli

manuel aldana schrieb:
> Hi,
> 
> I am using the BeanEditor Form for editing users. For that I would like 
> to have a "partial" editing form, i.e. I want to protect certain columns 
> from being edited.
> 
> Example is the id of the object: Once it is created I want to have it 
> visible but not editable. Using the @NonVisual flag or exlude parameter 
> of BeanEdit-Form component wouldn't do this, it would just remove the 
> column from the frontend completely. I had a look at <t:parameter> 
> overrides but it does not seem to support a read-only flag.
> 
> Generally I would need something more flexible how to tell whether a 
> parameter is read-only or editable inside the form. For my current 
> problem the read-only vs. editable depends on roles (i.e. different 
> roles have different access rights to edit certain fields).
> 
> thanks.
> 


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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by manuel aldana <al...@gmx.de>.
Thiago H. de Paula Figueiredo schrieb:
> Em Sat, 18 Apr 2009 13:00:19 -0300, manuel aldana <al...@gmx.de> 
> escreveu:
>
>> Yes, but as you said it is a workaround and looks not good inside the 
>> template.
>> I think it is quite a common formular use-case, that some data 
>> columns are displayed but are read only during editing a data-item 
>> (e.g. id, email, username). I see such a thing in many webapps. 
>> Because bean-edit-form is the handy formular component of tapestry 
>> such a support would be very nice.
>
> Adding this feature would need to change BeanEditForm, BeanEditor, 
> PropertyEditContext and eventually every single edition block, 
> provided by Tapestry or not. Good luck trying to convince Howard: at 
> http://www.nabble.com/Tabindex-and-accesskey-in-BeanEditForm--to22380749s302.html#a22420266. 
>
OK, let's hope Howard comes across this thread and adds his cents ;)
As said such read-only columns in formulars are quite typical.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 18 Apr 2009 13:00:19 -0300, manuel aldana <al...@gmx.de> escreveu:

> Yes, but as you said it is a workaround and looks not good inside the  
> template.
> I think it is quite a common formular use-case, that some data columns  
> are displayed but are read only during editing a data-item (e.g. id,  
> email, username). I see such a thing in many webapps. Because  
> bean-edit-form is the handy formular component of tapestry such a  
> support would be very nice.

Adding this feature would need to change BeanEditForm, BeanEditor,  
PropertyEditContext and eventually every single edition block, provided by  
Tapestry or not. Good luck trying to convince Howard: at  
http://www.nabble.com/Tabindex-and-accesskey-in-BeanEditForm--to22380749s302.html#a22420266.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by manuel aldana <al...@gmx.de>.
Thiago H. de Paula Figueiredo schrieb:
>> I see, but how do I set a property to be read only?
> Sorry, I misundestood your question. Answer: you don't set a property 
> to be read only. The workaround is to override an edition block with 
> <t:parameter>.
Yes, but as you said it is a workaround and looks not good inside the 
template.

>> <beaneditform .... readonly="literal:foo,bar"/>
>> or even better, to let it control through page class:
>> <beaneditform .... readonly="prop:readOnlyParameters"/>
> Maybe it would be cool to add a new component parameter (readonly) to 
> BeanEditForm:
>
> That's not how BeanEditForm/BeanEditor is meant to be used.
I think it is quite a common formular use-case, that some data columns 
are displayed but are read only during editing a data-item (e.g. id, 
email, username). I see such a thing in many webapps. Because 
bean-edit-form is the handy formular component of tapestry such a 
support would be very nice.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 18 Apr 2009 12:42:33 -0300, manuel aldana <al...@gmx.de> escreveu:

> I see, but how do I set a property to be read only?

Sorry, I misundestood your question. Answer: you don't set a property to  
be read only. The workaround is to override an edition block with  
<t:parameter>.

> Maybe it would be cool to add a new component parameter (readonly) to  
> BeanEditForm:
> <beaneditform .... readonly="literal:foo,bar"/>
> or even better, to let it control through page class:
> <beaneditform .... readonly="prop:readOnlyParameters"/>

That's not how BeanEditForm/BeanEditor is meant to be used.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by manuel aldana <al...@gmx.de>.
Thiago H. de Paula Figueiredo schrieb:
> Em Sat, 18 Apr 2009 07:38:53 -0300, manuel aldana <al...@gmx.de> 
> escreveu:
>
>> Generally I would need something more flexible how to tell whether a 
>> parameter is read-only or editable inside the form. For my current 
>> problem the read-only vs. editable depends on roles (i.e. different 
>> roles have different access rights to edit certain fields).
>
> This is easy: create a method that returns a BeanModel that will be 
> passed to BeanEditForm/BeanEditor. This method will remove or reorder 
> BeanModel properties according to your requirements.

I see, but how do I set a property to be read only?

Looking at the api 
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.html) 
I couldn't find such a thing.

Maybe it would be cool to add a new component parameter (readonly) to 
BeanEditForm:
<beaneditform .... readonly="literal:foo,bar"/>

or even better, to let it control through page class:
<beaneditform .... readonly="prop:readOnlyParameters"/>

If/else constructs would work inside the page-template, but don't look 
nice if there are many parameters. They really pollute the page template.

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sat, 18 Apr 2009 07:38:53 -0300, manuel aldana <al...@gmx.de> escreveu:

> Generally I would need something more flexible how to tell whether a  
> parameter is read-only or editable inside the form. For my current  
> problem the read-only vs. editable depends on roles (i.e. different  
> roles have different access rights to edit certain fields).

This is easy: create a method that returns a BeanModel that will be passed  
to BeanEditForm/BeanEditor. This method will remove or reorder BeanModel  
properties according to your requirements.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by Ulrich Stärk <ul...@spielviel.de>.
Unless someone modifies the DOM and sets it to true. So in your page class you also want to make 
sure that the value is not updated when readonly is set to true.

Uli

On 29.03.2010 23:13, aash wrote:
>
> i spent hours and hours trying to figure out why TextField didn't simply have
> a 'readonly' parameter, which would fix this issue.  the answer was pretty
> simple, and caused me to utter a heartfelt "UGH!"
> you CAN use readonly.  it just gets passed from the TextField thing to the
> <input>  tag.
>
>      <t:beaneditform t:id="thingEdit"
>          object="thing"
>          submitLabel="message:button.save"
>      >
>          <t:parameter name="id">
>              <t:label for="id"/>
>              <t:textfield t:id="id" value="thing.id" readonly="true"/>
>          </t:parameter>
>      </t:beaneditform>
>
> It will show up looking editable just like the other fields, but indeed will
> not be.
>
> aash
>
>
> aldana wrote:
>>
>> Hi,
>>
>> I am using the BeanEditor Form for editing users. For that I would like
>> to have a "partial" editing form, i.e. I want to protect certain columns
>> from being edited.
>>
>> Example is the id of the object: Once it is created I want to have it
>> visible but not editable. Using the @NonVisual flag or exlude parameter
>> of BeanEdit-Form component wouldn't do this, it would just remove the
>> column from the frontend completely. I had a look at<t:parameter>
>> overrides but it does not seem to support a read-only flag.
>>
>> Generally I would need something more flexible how to tell whether a
>> parameter is read-only or editable inside the form. For my current
>> problem the read-only vs. editable depends on roles (i.e. different
>> roles have different access rights to edit certain fields).
>>
>> thanks.
>>
>> --
>>   manuel aldana
>>   aldana@gmx.de
>>   software-engineering blog: http://www.aldana-online.de
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>> -----
>> manuel aldana
>> aldana((at))gmx.de
>> software-engineering blog: http://www.aldana-online.de
>>
>

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


Re: [bean-edit-form] make a sub-set of parameters visible but not editable

Posted by aash <aa...@stdio.com>.
i spent hours and hours trying to figure out why TextField didn't simply have
a 'readonly' parameter, which would fix this issue.  the answer was pretty
simple, and caused me to utter a heartfelt "UGH!"
you CAN use readonly.  it just gets passed from the TextField thing to the
<input> tag.

    <t:beaneditform t:id="thingEdit"
        object="thing"
        submitLabel="message:button.save"
    >
        <t:parameter name="id">
            <t:label for="id"/>
            <t:textfield t:id="id" value="thing.id" readonly="true"/>
        </t:parameter>
    </t:beaneditform>

It will show up looking editable just like the other fields, but indeed will
not be.

aash


aldana wrote:
> 
> Hi,
> 
> I am using the BeanEditor Form for editing users. For that I would like 
> to have a "partial" editing form, i.e. I want to protect certain columns 
> from being edited.
> 
> Example is the id of the object: Once it is created I want to have it 
> visible but not editable. Using the @NonVisual flag or exlude parameter 
> of BeanEdit-Form component wouldn't do this, it would just remove the 
> column from the frontend completely. I had a look at <t:parameter> 
> overrides but it does not seem to support a read-only flag.
> 
> Generally I would need something more flexible how to tell whether a 
> parameter is read-only or editable inside the form. For my current 
> problem the read-only vs. editable depends on roles (i.e. different 
> roles have different access rights to edit certain fields).
> 
> thanks.
> 
> -- 
>  manuel aldana
>  aldana@gmx.de
>  software-engineering blog: http://www.aldana-online.de
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> -----
> manuel aldana
> aldana((at))gmx.de
> software-engineering blog: http://www.aldana-online.de
> 

-- 
View this message in context: http://old.nabble.com/-bean-edit-form--make-a-sub-set-of-parameters-visible-but-not-editable-tp23111464p28075272.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