Re: Custom Component Problems
Re: Custom Component Problems
- Subject: Re: Custom Component Problems
- From: Chuck Hill <email@hidden>
- Date: Mon, 19 Mar 2007 14:07:44 -0700
On Mar 19, 2007, at 1:37 PM, Jorge Ramirez wrote:
Thanks for the help so far Chuck. Sorry for the misunderstanding.
The PermissionComponent only has one WOComponentContent inside of
it, and then i include multiple PermissionComponents (one for each
field i want to monitor) on the editUser page.
I am pretty sure that is still not allowed. You can hide them all
you want, but more than one WOComponentContent is still more than one.
When i started, i did it the way you had mentioned, a base class,
and then a component for each interface style that i wanted. I
remember now why i didn't do that (because i wasn't familiar enough
with creating custom components).
That leads me to a different question: if i do it that way (a
different component for each ui style), and i have a
TextFieldPermissionComponent, what if i want to set custom bindings
on the textfield inside of that component from the page that it is
on. So lets say on the editUser page, i want the firstName
textfield to have a 'size' of 15 and the middleName textfield to
have a 'size' of 5. Would i have to create a binding in my
TextFieldPermissionComponent for every possible binding that i
would want to set on the textfield, or can i make it stateless and
it will pass all of the bindings to the textfield automatically?
I'd just use the carat notation (it says "get this from my parent").
Text: WOTextField {
value = ^value;
size = ^size;
class = ^class;
style = ^style;
id = ^id;
}
Gives you what you want, plus optional style, class, and id.
Personally, I would make components like this stateless however you
then have to deal with retaining validation messages and such. I
push this responsibility up to the parent.
Chuck
On 3/19/07, Chuck Hill <email@hidden> wrote:
On Mar 19, 2007, at 1:07 PM, Jorge Ramirez wrote:
> Sure, i have an example below:
>
> I have an editUser page. That page has a spot for editing the
> user's first name, last name, etc...
> Each of the textfields for editing the user's attributes (first
> name, last name, etc..) are wrapped in a PermissionComponent (the
> component mentioned before). The bindings are listed below for the
> firstNamePermissionComponent, which wraps the firstNameTextField.
>
> firstNamePermissionComponent : PermissionComponent
> {
> readPermissionName = "User.readFirstName";
> writePermissionName = " User.readWriteName";
> record = user;
> value = user.firstName ;
> }
>
> firstNameTextField : WOTextField
> {
> value = user.firstName;
> }
>
>
> Then the PermssionComponent calls the PermissionManager, determines
> weather the currently logged in user has the given permissions, and
> then determines weather to show a permissioned denied string, a
> string with the value of the 'value' binding, or a component content
That might be your problem. You can only use a single
WOComponentContent on a page. I think your basic design is sound.
What I would do is to merge the two so that the WOTextField became
part of PersmissionComponent (so you would have
TextFieldPermissionComponent, PopupPermissionComponent, etc. All the
code would be in PermissionComponent, the subclasses would just
provide a UI. That way you can use WOConditional instead of
WOComponent content. FWIW, that is how I do it.
> (in this case the content would be the textfield). The component
> is currently synchronizing right now. I wasn't sure if it should
> be or not.
It is a question of optimization. But if it was stateless or non-
synching that might suggest other causes of your problem.
Chuck
>
>
> On 3/19/07, Chuck Hill <email@hidden> wrote:
> On Mar 19, 2007, at 12:10 PM, Jorge Ramirez wrote:
>
> > Hello, i am having a problem creating a custom re-usable
> > component. I am fairly new to WebObjects, so forgive me if i am
> > going about this all wrong. The problem is as follows:
> >
> > I have groups, users and permissions in my application. The users
> > are members of groups and the groups get assigned permissions.
> >
> > I want to be able to, based on weather the user has read/read and
> > write/no permission on an object's attributes, display one of the
> > following:
> > a string (if the user has read only access)
> > a textfield/popupmenu/etc... (if the user has read and write
access)
> > a permission denied string (if the user does not have permission)
> >
> > I have created a component with the following bindings:
> > readPermissionName (the name of the permission required to have
> > read access for the attribute on the given object)
> > writePermissionName (the name of the permission required to have
> > write access for the attribute on the given object)
> > record (the record in question)
> > value (the string value of the attribute)
>
> Can you give an example of this binding?
>
>
> > the component then either displays:
> > a permission denied string if the user does not have permission
> > a string with the string value of the attribute if the user has
> > read only access
> > or a component content if the user has read and write access (in
> > the component that would use this component, i would put a
> > textfield, or popup menu in the component content area)
> >
> > It appears to work in the way that it displays either a string, a
> > permission denied string, or whatever i put in the
componentcontent
> > area. The problem i am having is when i want to save the value of
> > lets say a textfield in the read/write component content area.
The
> > value is not getting pushed back to the object when i call
> > saveChanges();
> >
> > I think it might have something to do with the caret symbol, but i
> > have never been too clear on when to use that and when not to use
> > that. Does anyone have any ideas?
>
> Is the component non-synchronizing (with its bindings) or stateless?
>
> Chuck
>
> --
>
> Practical WebObjects - for developers who want to increase their
> overall knowledge of WebObjects or who are trying to solve specific
> problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden