Hi,
When editing a structure, accessors are called via Magritte but there
is no way for the structure to reinitialize itself before any accessor
is called, or to re-establish its invariant after all accessors have
been called.
I thought I'd wrap PRCommand>>doExecute with something like self
structure willEdit and self structure didEdit, would that make sense?
I also saw PRStructure>>validateCommand which shouldn't modify the
structure, but in my case (Citezen) validating means parsing that
takes time and I'd prefer not to repeat that work when committing the
edition to the structure.
I think writing this helped me see a solution:
- validation does the heavy parsing and stores result in (an adhoc
subclass of) the edit command
- executing the command stores parsed data in the structure and resets
the final data
- a lazy accessor for the final data builds it and ditches the parsed data
hopefully that was clear… if you have suggestions…
--
Damien Pollet
type less, do more [ | ] http://typo.cdlm.fasmz.org
Hello,
At present magritte is a little limited when you have two form fields
which are related in some way. I have come up with a scheme which works,
suggestions are of course very welcome.
Here is an example from the top....
description0020ServiceType
^ MASingleOptionDescription new
accessor: ((#serviceType asAccessor) update:
#serviceTypeChangedTo:);
reference: MAClassDescription new;
options: [ DTIServiceTypes allSubclasses ] asDynamicObject;
default: DTIDeliveryWholesale;
componentClass: MASelectListComponentSU ;
beRequired;
bePersisted;
yourself
Service type is select list which changes the values in other fields in
the form, when the users switches it.
1. The first innovation is the setting of the priority in the method
selector name. I have used this for 3 days and it works really well.
(Enhancement available in Magritte-CustomBuilder package)
2. The second innovation is ((#serviceType asAccessor) update:
#serviceTypeChangedTo:) This is shorthand for...
(MASelectorAccessor read: #serviceType write: #serviceType:)
propertyAt: #update put: (MASelectorAccessor write:
#serviceTypeChangedFix:)
So we have normal access to the datamodel via the reading and writing
accessors, this is the sort of accessing that persisting (and mementos)
would use, but GUI elements can use additional optional update accessor.
#serviceTypeChangedTo: will modify other fields in the model. (Well
actually the model's memento but we will come to that).
Where GUI elements used to write to objects using the standard
Object-#write:using: there is now an #Object-#update:using: which uses
the update accessor if present.
3. RealMementos
The problem with the way that the Gui does mementos now is that it
operates on a dictionary of the models data. The mementos have no
awareness of the model itself. Enter MARealMemento... This uses a
dictionary checks as before BUT importantly read/writes from the GUI are
performed upon a real copy of the model, which is returned upon commit/save.
It also has methods (not yet used) #snapshot, and
#hasChangedSinceSnapshot, which the gui can us in order to only up date
items which have changed since the previous update.
This means that the update methods can modify the values in other fields
and the GUI will see these changes if it is re-rendered using Scriptaculous.
Two caveats are that items being edited by an InternalEditor will will
need to a) have an MAStraitMemento so that they operate directly on the
same model (since they are in the same UI) and (b) the internally edited
objects must be modified not replaced (since the InternalEditor
currently has and is likely to keep a reference to the object itself)
4. MASelectListComponentSU
The scriptaculous addition to the standard select list component, calls
the #update: accessor when the users changes the selection, and it
renders updateContentOn: of the containing MAContainerComponent. So the
display of all fields is refreshed.
I have one other refinement... (not yet implemented in this form)
5. Modifying readonly isVisible
accessor: ((#check asAccessor) readonly: #isCheckDisabled);
accessor: ((#check asAccessor) visible: #isCheckVisible);
The code so far is available in Magritte-RealMemento ,
Magritte-Scriptaculous, Magritte-CustomBuilder
I think that this potentially moves magritte up a level in
user-interactivity
enjoy
Keith
Hi,
I have the following problem with CSS and Firefox
On http://moose.unibe.ch I have a CSS file that is pointed to as
stylesheet from the root page. On Safari 3.0 and on Internet Explorer
it looks Ok, but on Firefox it looks as if the CSS cannot be found.
What could the problem be?
Cheers,
Doru
--
www.tudorgirba.comwww.tudorgirba.com/blog
"Next time you see your life passing by, say 'hi' and get to know her."
Hi again,
I have a blog moose.unibe.ch/news, but the RSS link points to
localhost. What could be the problem?
I should say that there is an Apache rewrite rule that forwards
moose.unibe.ch to localhost.
Cheers,
Doru
--
www.tudorgirba.comwww.tudorgirba.com/blog
"One cannot do more than one can do."
Hi all,
I'm using Magritte to model some objects of mine and basically if the
user edits the object I want the description to be the same, just the
"unique key" to become read only. If they add then of course all
fields are modify-able.
I have done this by overriding #description on instance side to do
something like:
MyObject>>description
|result|
result := self class description.
^ someField
ifNil: [ result ] "new instance"
ifNotNil: [
result collect: [e|
e label = 'Name Im interested in'
ifTrue: [ e beReadonly; yourself ]
ifFalse: [ e ] ] ]
Now of course what happens is, if I click edit first then the fields
are always read only and vice versa if I click new first, due to
caching. That is, it works perfectly.... the first use, and from then
on #description is called. Before I fought with this anymore I
thought I would check if there is a simpler way to do what I'm trying
to do.
Thanks in advance,
Jason
Hi,
I am looking to see how do you handle the security in Pier.
I am trying to read the code but if you have a short explanation or
some pointer the would help.
Sorry if someone have already ask the question. I am to lazy to search
throw the mailing-list :0.
Thanks
Mth
Hi,
I have troubles starting the ImagePersitency. I did the following:
PRKernel instances anyOne persistency: PRImagePersistency new
But, nothing seems to happen when I edit.
What am I doing wrong?
Doru
--
www.tudorgirba.comwww.tudorgirba.com/blog
"Every thing has its own flow."
In Pier-Math it's just fixes mainly because it hardcoded the paths to
latex and dvipng.
I added a new subclass of PRTagCloudWidget with a different formula
for scaling the tags:
- it computes mean and standard deviation in occurences among the
displayed tags,
- tags in the mean get 100% size
- the scaling tends towards a factor of +/- two for outliers
- tags at standard deviation are visibly scaled (I don't remember
exactly but twice the std dev would give 80-90% of maximum scaling)
No commit comment because the Accept button threw itself under a click :)
--
Damien Pollet
type less, do more [ | ] http://typo.cdlm.fasmz.org