incubator-isis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Meyer - KMZ" <ke...@kmz.co.za>
Subject Re: Wicket Viewer - fetching choices for value types
Date Sat, 09 Jul 2011 14:47:21 GMT
Hi Dan,

I got quite far, to the extend that I was able to render the choices in a 
drop-down list, but I *still* had the original input field as a free-form 
entry box.

While trying to address this, I got stuck again.

Anyway!

If ComponentFactoryScalarAbstract#createComponent, I have some 
code (currently commented out) that looks like this:

    public final Component createComponent(final String id, final IModel<?> model) {
        final ScalarModel scalarModel = (ScalarModel) model;

        // TODO: This is where the ValueCollection panel gets created.
        final List<ObjectAdapter> choices = scalarModel.getChoices();
        if (choices.size() > 0) {
	return new ValueCollection(id, scalarModel);
        } else {
        	return createComponent(id, scalarModel);
        }
    }

The point is that if a property of any of the regular scalarModel types is 
found to have some choices, then instead of creating the normal 
component (e.g. StringPanel), the factory creates a ValueCollection 
(ok, the name can be changed).

As I see it, this value collection simply needs to render a the value type 
as a dropdown list...

But I'm getting stuck trying to synchronise the HTML and the wicket 
viewer code in ValueCollection.

I'm going to stop here for a while, but would appreciate it if you could 
uncomment the block in ComponentFactoryScalarAbstract, above, 
and have a look at my ValueCollection.java & html.

I deleted what turned out to be unneeded changes to the 
ComponentFactoryListDefault.java, ComponentType.java, etc, and 
deleted the unneeded ValueCollectionFactory.java.

Regards,
Kevin



On 8 Jul 2011 at 21:33, Kevin Meyer - KMZ wrote:

> Further to my previous email, I have done a little exploring, and have 
> realised that "ScalarPanelTextFieldAbstract" might be a place to start 
> looking.
> 
> As an experiment, I put a hook into "addSemantics":
>         final List<ObjectAdapter> choices = scalarModel.getChoices();
>         if (choices.size() > 0) {
>             // return null;
>             choiceCount = choices.size();
>         }
> 
> And I get a hit with my domain's value property's choicesXXX method.
> 
> Am I heading in the right direction?  I would assume that somewhere 
> in here I could start providing the viewer with an alternate rendering 
> (dropdown list) when choiceCount > 0 is detected.
> 
> Regards,
> Kevin
> 
> 
> On 7 Jul 2011 at 16:03, Kevin Meyer - KMZ wrote:
> 
> > Hi Dan,
> > 
> > I've created a JIRA ticket:
> > https://issues.apache.org/jira/browse/ISIS-105
> > 
> > I've created a factory and added it to the 
> > ComponentFactoryListDefault, but I can't get the "appliesTo" method 
> > to ever be called... 
> > 
> > I think I am missing something somewhere else in the initialisation / 
> > in(tro)spection, to catch value types..
> > 
> > Any additional suggestions?
> > 
> > Regards,
> > Kevin
> > 
> > 
> > On 7 Jul 2011 at 8:17, Dan Haywood wrote:
> > 
> > > Have a look at the DropDownChoicesForObjectAdapterMementos class, and 
> > > how it is currently used to render choices for references (the 
> > > EntityLink class).  Also have a look at EntityLink.html which shows the 
> > > corresponding markup into which this drop-down component goes.
> > > 
> > > But I'm a bit rusty with the Wicket viewer myself, so can't tell you 
> > > much more than that without drilling into it for an hour.  Have a go 
> > > yourself, but if you end up going round in circles then come back to me 
> > > and I'll try to delve into it a little more deeply myself.
> > > 
> > > Cheers
> > > Dan


Mime
View raw message