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

"Christian Cryder" <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Ok, this is done! I believe I have all the changes properly applied, but I'm
not sure how to test the contrib stuff...Diez and Steven...could you guys
update from cvs and confirm/deny whether things still work there?

You can see exactly what I changed by searching for //csc_030703.1

All the unit tests work, and I have rebuilt the jars.

THanks,
Christian
----------------------------------------------
Christian Cryder [[email protected]]
Internet Architect, ATMReports.com
Barracuda - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"
  -----Original Message-----
  From: [email protected]
[mailto:[email protected]]On Behalf Of Jacob Kjome
  Sent: Friday, March 07, 2003 9:24 AM
  To: [email protected]
  Subject: RE: [Barracuda] problems with recent change in TemplateModel....



  Hi Christian,

  If you want to go ahead and make the necessary changes, that would be
great.  I agree that having both getItem() methods in the interface confuses
things.  This was just a short term solution to get everything compiling and
working properly until we deciding to fix things.

  To do a clean rebuild of the contrib stuff without recompiling everything
else do.....

  ant contrib -Dclean.contrib=true -Dsubskip=true

  to clean everything do...

  ant superclean contrib -Dsubproject=all -Dsubtarget=superclean

  That will clean Barracuda, Build Barracuda + contrib, and then clean up
each of the contrib projects

  to install the contrib projects to Tomcat to verify that they work after
changes do...

  ant contrib -Dsubproject=all -Dsubtarget=catalina-install


  later,

  Jake

  At 08:21 AM 3/7/2003 -0500, you wrote:

    Hi Jake!

    My bad. I forgot to check the contrib directory. What I'd like to do is
completely remove the getItem(String key) method, simply because it
complicates the interface - it really should have been
getItem(TemplateDirective td) from the beginning. I'm concerned that if we
leave it folks will look at the interface and go "do I need to implement
both???"

    All that should be required is to change the signature in any classes
that implement TemplateModel. So instead of this:

        public Object getItem(String key)
            ...

    they'd do this:

        public Object getITem(TemplateDirective td)
            String key = td.getKeyName();
            ...

    pretty straightforward and easy to do. I'd be happy to make the change
to all the contrib code if you'd like, since its my change that is causing
the trouble.

    Alternatively, any code that implements TemplateModel could be modified
to extend from AbstractTemplateModel, and all should be well that way too.

    Of course, any classes that utilize TemplateModel from above (like
TemplateHelper, or in Diez' case, FilterFactory) have to be modified as
well. Again, these are relatively trivial changes, but they are changes
nonetheless.

    So let me know what you think - I'd really like to just get to the one
new getItem() method, as opposed to two. However, I also realize that my
change as I made it yesterday does in fact break some existing code (which
is never good ;-) so I'd be happy to help fix the mess. Or if you are
comfortable making the changes to the contrib package, we could do it that
way too.

    My guess is that outside of the Barracuda framework, there aren't too
many people out there actually implementing TemplateModel directly.

    Christian





    ----------------------------------------------
    Christian Cryder [[email protected]]
    Internet Architect, ATMReports.com
    Barracuda - http://barracudamvc.org
    ----------------------------------------------
    "Coffee? I could quit anytime, just not today"

      -----Original Message-----

      From: [email protected]
[mailto:[email protected]]On Behalf Of Jacob Kjome

      Sent: Thursday, March 06, 2003 10:49 PM

      To: [email protected]

      Subject: [Barracuda] problems with recent change in TemplateModel....



      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.jav
a: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.jav
a: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.jav
a: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/b
uild

      -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.