Re: problems with recent change in TemplateModel....

Jacob Kjome <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Just a follow-up.  I made some changes that seem to break the code 
less.  Here is the log message...

Log message:
         modified TemplateModel by uncommented the getItem(String key) 
method that was previously commented out in favor of 
getItem(TemplateDirective td) by Christian.  Christian assumed that this 
wouldn't be much of an issue, but there are some classes out there 
(especially in the contrib packages) that implement TemplateModel directly 
and don't extend AbstractTemplateModel.  The siimplest thing to do and what 
will cause the least breakage is to put both getItem() methods in the 
interface.  If it is later determined that only the contrib packages have a 
real problem with this, then they can change and we can re-comment out 
getItem(String key) in TemplateModel.  Until then, this makes things 
compile and work.


With the getItem(String) added back in, all I had to do was add the 
following to a few classes and everything works in the contrib packages 
again...

public Object getItem(TemplateDirective td) {
         return getItem(td.getKeyName());
}

Otherwise, there was a lot of possibly tedious work to do to make things 
work with Diez' form mapping stuff.  Like I said above, if it is determined 
by Deiz and Stefan that changes to their apps to support the single 
getItem(TemplateDirective) method wouldn't be too hard to implement and 
other users don't think it will be of issue, then I'm all for re-removing 
the getItem(String) method from the TemplateModel interface.

Let me know what you think of this change.  I think it is the least 
painful...at least in the short term.  We can evaluate the long term and 
definitely make a determination before the next release.

Jake


At 09:48 PM 3/6/2003 -0600, you wrote:

>Hi Christian,
>
>I noticed that you modified TemplateModel to take a TemplateDirective in 
>getItem().
>
>You said this...
>
>Log message:
>         <b>csc_030603.2</b> - changed the signature of the getItem() 
> method in the
>         TemplateModel interface from:
>         getItem(String key)
>         to:
>         getItem(TemplateDirective td)
>         This gives the model implementation access to the full 
> TemplateDirective, and opens
>         up some interesting pattern opportunities based on the key data 
> portion of directives
>         (rather than on a naming convention applied to key name, which 
> was the only option
>         available before). While changing the signature might seem like 
> it will have a big impact
>         on existing code, I don't think it will do so because 
> AbstractTemplateModel implements
>         this method and simply calls the old getItem(String key) method. 
> So old code should
>         continue to work, but it you want to implement something under 
> the new signature, you
>         certainly can. The only caveat is that if you implement this new 
> method directly, you
>         should make sure you call super.getItem() for TemplateDirectives 
> that go unhandled.
>         or are still handled in the old getItem(String key) method.
>
>but it results in the following errors in the contrib projects and that 
>doesn't even include the contrib webapps, that's just the main contrib 
>package....
>
>compile.contrib:
>     [javac] Compiling 4 source files to 
> D:\myclasses\Repository\Enhydra\Barracud
>aMVC_2003-02-17\Barracuda\WEB-INF\classes
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\dbroggisch\display\filters\FilterFactory.java:46
>8: getItem(org.enhydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.bar
>racuda.core.comp.TemplateModel cannot be applied to (java.lang.String)
>     [javac]                     res.setItem((String)entry.getValue(), 
> ltm.getIte
>m((String)entry.getKey()));
>     [javac] 
>     ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\dbroggisch\display\filters\FilterFactory.java:47
>8: getItem(org.enhydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.bar
>racuda.core.comp.TemplateModel cannot be applied to (java.lang.String)
>     [javac]                             res.setItem(key, 
> f.filter(ltm.getItem(ke
>y), ctx));
>     [javac]                                                              ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\dbroggisch\display\filters\FilterFactory.java:48
>3: getItem(org.enhydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.bar
>racuda.core.comp.TemplateModel cannot be applied to (java.lang.String)
>     [javac]                             res.setItem(key, ltm.getItem(key));
>     [javac]                                                     ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\dbroggisch\repopulation\RepopulationFormMap.java
>:38: 
>org.enhydra.barracuda.contrib.dbroggisch.repopulation.RepopulationFormMap s
>hould be declared abstract; it does not define 
>getItem(org.enhydra.barracuda.cor
>e.comp.TemplateDirective) in 
>org.enhydra.barracuda.contrib.dbroggisch.repopulati
>on.RepopulationFormMap
>     [javac] public class RepopulationFormMap extends ErrorFormMap 
> implements Tem
>plateModel {
>     [javac]        ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:23: 
>org.enhydra.bar
>racuda.contrib.sam.models.MapDecorator should be declared abstract; it 
>does not
>define getItem(org.enhydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra
>.barracuda.core.comp.TemplateModel
>     [javac] public class MapDecorator extends TemplateModelDecorator {
>     [javac]        ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:63: 
>getItem(org.enh
>ydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.T
>emplateModel cannot be applied to (java.lang.String)
>     [javac]         Object value = _templateModel.getItem(key);
>     [javac]                                      ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:75: 
>getItem(org.enh
>ydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.T
>emplateModel cannot be applied to (java.lang.String)
>     [javac]             value=mapItemAsLookup(key, 
> _templateModel.getItem(key),
>(Map)mapper );
>     [javac]                                                      ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:77: 
>getItem(org.enh
>ydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.T
>emplateModel cannot be applied to (java.lang.String)
>     [javac]             value=mapItemAsNumberFormat(key, 
> _templateModel.getItem(
>key), (NumberFormat)mapper );
>     [javac]                                                            ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:79: 
>getItem(org.enh
>ydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.T
>emplateModel cannot be applied to (java.lang.String)
>     [javac]             value=mapItemAsDateFormat(key, 
> _templateModel.getItem(ke
>y), (DateFormat)mapper );
>     [javac]                                                          ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:81: 
>getItem(org.enh
>ydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.T
>emplateModel cannot be applied to (java.lang.String)
>     [javac]             value=mapItemAsEvent(key, 
> _templateModel.getItem(key), (
>ControlEvent) mapper);
>     [javac]                                                     ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:157: 
>getItem(org.en
>hydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.
>TemplateModel cannot be applied to (java.lang.String)
>     [javac]                             label = 
> (String)_templateModel.getItem(l
>abel);
>     [javac]                                                               ^
>     [javac] 
> D:\myclasses\Repository\Enhydra\BarracudaMVC_2003-02-17\Barracuda\sr
>c\org\enhydra\barracuda\contrib\sam\models\MapDecorator.java:176: 
>getItem(org.en
>hydra.barracuda.core.comp.TemplateDirective) in 
>org.enhydra.barracuda.core.comp.
>TemplateModel cannot be applied to (java.lang.String)
>     [javac]                                     v = (String) 
> _templateModel.getI
>tem( v);
>     [javac] 
>       ^
>
>     [javac] 12 errors
>
>BUILD FAILED
>file:D:/myclasses/Repository/Enhydra/BarracudaMVC_2003-02-17/Barracuda/src/build
>-contrib.xml:84: Compile failed; see the compiler error output for details.
>
>
>I'm afraid that this might be a big deal to some people.  If this is going 
>to be the way it is and it provides benefits that outweigh the pain of 
>fixing all these errors, then I'm fine with the change, but I want to make 
>sure that this is what we want before I start trying to fix the contrib 
>and my other apps.
>
>Jake
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.