• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Error when trying to use an included file

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
Try to include a file to use its fucntions but get the next error :
-----------------------------------------------------------------------------------------------------------------------------------------------------------
groovy.lang.MissingMethodException: No signature of method: CsvToHtml_der.formatPage() is applicable for argument types: (java.lang.String, java.lang.String) values: [Resultat, a;z;e;r;t;y;u;i;o;p;
            q;s;d;f;g;h;j;k;l;m;
            w;x;c;v;b;;n;n;n;n;]
--------------------------------------------------------------------------------------------------------------------------------------------------------------
File to be included :
import groovy.xml.MarkupBuilder
       
def formatRow = { doc, row ->
   doc.tr { row.each { cell -> td { mkp.yield(cell) } } }
}

def formatPage = { String titleString,String csv, header=false ->
   def writer = new StringWriter()
   def doc = new MarkupBuilder(writer)
   def rows = csv.split('\n').collect { row -> row.split(';') }
   doc.html {
       head {
           title (titleString)
           style (type:"text/css") {
               mkp.yield('''
                   td {background-color:#ddddff; }
                   thead td {background-color:#ddffdd; text-align:center; }
               ''')
           }
       }
       body {
           table (border:1) {
               header && thead { formatRow(doc, rows[0]) }
               header && tbody { rows[1..-1].each { formatRow(doc, it) } }
               header || rows.each { formatRow(doc, it) }
           }
       }
   }
  return writer.toString()
}



------------------------------------------------------------------------------------------------------------------------------------------------------------
File where stands the include :


evaluate (new File("C:\\groovy-2.4.12\\script_lib\\CsvToHtml.groovy"))


def String csv = '''a;z;e;r;t;y;u;i;o;p;
            q;s;d;f;g;h;j;k;l;m;
            w;x;c;v;b;;n;n;n;n;'''

println 'Basic:'
println '-----------------------------------------'
println (formatPage('Resultat', csv))
println '-----------------------------------------'


an idea on the fix ?
Thanks for the help
 
author & internet detective
Posts: 40746
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jag,
Welcome to CodeRanch!

The evaluate() call executes the Groovy. It doesn't logically copy/paste it. What you can do is have your included groovy file define a class and return an instance. Then the calling code can write myIncludedFile.formatPage().
 
reply
    Bookmark Topic Watch Topic
  • New Topic