Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sapphire-dev] updating display text based on model

Ok, I figured sapphire had support for this, thanks for pointing me in the right direction.  So now I have this desclaration on my model:

@DerivedValue(service = PreviewSourceContentProvider.class)
@DependsOn({ "RequiredAttributes", "Events", "OtherAttributes" })
ValueProperty PROP_PREVIEW = new ValueProperty(TYPE, "Preview");

Value<String> getPreview();

And in the sdef, I have this:

            <composite>
                <content>
                    <label>${preview}</label>
                </content>
            </composite>

However, I am only seeing the preview property be read once initially and doesn't get updated when other model elements change.  One question I had was about propagation.  In my @DependsOn the properties that I list are actually ListPropertys.  And what is changing is not a node being added or removed from the list but rather a property one or more of the list elements themselves.  Does this type of @DependsOn work?  Does the @DependsOn look down into every child node for possible changes?

On Thu, Apr 21, 2011 at 11:35 AM, Konstantin Komissarchik <konstantin.komissarchik@xxxxxxxxxx> wrote:

Hi Greg,

 

There are two Sapphire constructs that can meet your requirements… label and html-content (renderers using embedded browser control). Chose one or the other depending on your text formatting needs. Both accept EL, so will update automatically when a property that EL references changes.

 

I suspect that the issue you are running into is at the model level…

 

> I have not been able to figure out how to do this.  In my model I have

> a value property where I specify a custom value binding to be computed

> and then I put a propertyEditor on this property in the UI.  The custom

> property is read once and displayed in the UI the first time but I don't

> know how to get sapphire to re-render this property based on model changes.

 

If the property editor over this custom property isn’t updating, the property in the model isn’t properly configured to know when to refresh. For a property whose value or validation state depends on other properties, you want to use @DependsOn annotation. List everything your computed property depends on and it will refresh automatically.

 

Also note that as of 0.2 release, Sapphire supports a concept of a derived property that seems to fit your requirements better than a standard ValueProperty. See 0.2 release’s what’s new document in the developer guide for further description and an example. Or maybe you can express your computed value via EL and skip the extra property entirely.

 

> I ran into problems trying to specify a custom part.

 

To resolve classes in sdef, you need to import the bundle and package where the class is located. See import section at the top of the sdef editor. Then use the unqualified class name in the body of the declaration. Do not suffix with “.class”.

 

But… it looks like support for custom parts has regressed recently in 0.3. The declaration in ISapphireCustomPartDef is not correct for how you are now supposed to reference java types from the model. I will fix that shortly.

 

- Konstantin

 

 

 

From: sapphire-dev-bounces@xxxxxxxxxxx [mailto:sapphire-dev-bounces@xxxxxxxxxxx] On Behalf Of Greg Amerson
Sent: Thursday, April 21, 2011 9:03 AM
To: Sapphire project
Subject: [sapphire-dev] updating display text based on model

 

Hi all,

 

I have a UI I'm working where I need a label or textbox at the bottom of my dialog that will display a string based that is computed based on the current values in the model.  As properties in the model change, I would like this display string to be recomputed and redisplayed as text.  I have not been able to figure out how to do this.  In my model I have a value property where I specify a custom value binding to be computed and then I put a propertyEditor on this property in the UI.  The custom property is read once and displayed in the UI the first time but I don't know how to get sapphire to re-render this property based on model changes.  Is this possible with Sapphire?

 

So this leads me to a second problem.  Since I didn't know how to solve this with my first approach, I decided to try to add a custom part to the UI.  With this custom SapphirePart I could just render a Label and then add a model listener and listen for property changes and update the label text accordingly.  However, I ran into problems trying to specify a custom part.  I added the Custom part and listed the new of the CustomSapphirePart.class in the sdef like this:

 

<composite>

                <content>

                    <custom>

                        <class>TagSourcePreviewPart.class</class>

                    </custom>

                </content>

            </composite>

 

 

However this doesn't seem to work as it can't find this class.  I debugged the code and it seems that there is no ReferenceService registered to be able to resolve the class.  Any help on how to specify custom sapphire parts would be appreciated.

 

Thanks in advance to whoever has time to help out with my questions.


--
Greg Amerson
Liferay, Inc.

East Coast Symposium 2011

May 10-11, 2011

Register today:  www.liferay.com/ECS2011

New! Attend Portal Administrator Training Express or Building Themes in Liferay on May 9 at the same location as ECS!

 


_______________________________________________
sapphire-dev mailing list
sapphire-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/sapphire-dev




--
Greg Amerson
Liferay, Inc.

East Coast Symposium 2011

May 10-11, 2011

Register today:  www.liferay.com/ECS2011

New! Attend Portal Administrator Training Express or Building Themes in Liferay on May 9 at the same location as ECS!



Back to the top