----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 17, 2002 4:07 AM
Subject: [Tapestry-developer] Log4j and static-binding help needed.


> Hi to all ,
> (Another lurker crawls out from the woodwork).
>
> Two quick questions that I'm hoping someone can give me some pointers on.
>
> Question 1
> ############
>
> Log4j. Can someone please give me specific instructions on how
> to get log4j working. I understand the configuration file ok, it's
> just I never get any output. Do I need to anything in setupLogging()
> method or should it just work!? I did get it to work once but
> not again.. Arrrrggh..

The easiest way is to ignore setupLogging() ... it's a bit of an anachronism
now.

What you need is a copy of log4j.properties in your classpath, at the root
(the default package).
The file is used to configure Log4J, identifying which categories are logged
at which levels, and where
log events go (to the console, to a file, etc.).

Examples of log4j.properties files are in a few different places of the
Tapestry distribution.


>
> BTW, I have a static class that I use to keep a handle to my logger:
> ie:
> public class Tigerangel {
>
>     public static  String SUITFRONT = "SUIT_FRONT";
>     public static  String SUITBACK = "SUIT_BACK";
>     public static  Category Log = Category.getInstance("TigerLogging") ;
// Log handle to Logger.

Better to do this as

    private static final Category CAT =
Category.getInstance(Tigerangel.class);

Although it isn't required, it is standard that a Class's category be
private and match its full class name.
Using the Tapestry inspector, you can create a new category that provides a
default logging level for
all classes in a package.  For example, if you create a package
"net.sf.tapestry" and give it the log level INFO, then every class (really,
every category) below net.sf.tapestry will using level INFO unless it
defines it own specific exception ... this is very powerful.

>
>
> }
>
> and to log message, do this:
> Tigerangel.Log.error(...);
>
> Any pointers???
>
>
> Question 2
> ############
>
> I have created a new component as such.
>
> =========================== Picture.jwc ========================
> <specification allow-informal-parameters="yes"
class="com.psaunders.tigerangel.tapestry.Picture">
>     <description> Get the specification for a picture given a product ID
and the picture type.
>         Picture type could be SUIT_FRONT, SUIT_BACK.</description>
>
>     <parameter  name="productTypeId" direction="in"
java-type="java.lang.String" required="no" />
>     <parameter  name="pictureType"   direction="in"
java-type="java.lang.String" required="no"/>
>     <parameter  name="productSize"   direction="in"
java-type="java.lang.Long" required="no"/>
>
>     <component id="insertName" type="Insert">
>         <binding name="value" property-path="pictureName"/>
>     </component>
>     <component id="e" type="Foreach">
>         <binding name="source" property-path="panels"/>
>     </component>
>     <component id="insertImage" type="Insert">
>         <binding name="value" property-path="components.e.value"/>
>     </component>
> </specification>
> ==========================================
>
> Though when I try to use it like this:
>
> ==========================
> Home.jwc ==================
> <specification class="net.sf.tapestry.html.BasePage">
>
>   <component id="mypicture" type="Picture">
>       <static-binding name="productTypeId">23</static-binding>
>       <static-binding name="productSize">10</static-binding>
>       <static-binding name="pictureType">SUIT_FRONT</static-binding>
>
>   </component>
>
> </specification>
> =================================================
>
> I get this exception:
> ========================== error output =================
> Can't find resource for bundle java.util.PropertyResourceBundle, key
ParameterManager.ParameterManager.static-initialization-failure

Looks like a little error in the code that generates an error message.  The
complete error report (including exception properties and stack trace) would
make it easy to identify what's wrong in your specification.

>
> component:
> net.sf.tapestry.html.BasePage@19e15c[Home]
>
> java.util.MissingResourceException
>
> Can't find resource for bundle java.util.PropertyResourceBundle, key
ParameterManager.ParameterManager.static-initialization-failure
>
> className:
> java.util.PropertyResourceBundle
>
> key:
> ParameterManager.ParameterManager.static-initialization-failure
>
> Stack Trace:
> java.util.ResourceBundle.getObject(ResourceBundle.java:314)
> java.util.ResourceBundle.getString(ResourceBundle.java:274)
> net.sf.tapestry.Tapestry.getString(Tapestry.java:471)
> net.sf.tapestry.Tapestry.getString(Tapestry.java:522)
> .
> .
> ======================================
>
> productSize is defined with getter and setter methods,
> and it is of type Long.

Please read the developer's guide.

You are providing a static binding, of type String, and telling Tapestry
that the JavaBeans property of your component is type String, but then the
accessor method is for type Long.  That is what Tapestry is generating an
error about.

A <static-binding> has code to automatically extract a String, boolean, int
or double value but Tapestry doesn't (currently) include conversions to
long.

I would guess that you are using the component on a test page (which is why
the values are constants).  I would suggest define public static fields with
the correct values, as long, i.e.

public class TestConstants
{
    public static final long PRODUCT_SIZE = 10;

The you can use a field binding:

  <field-binding name="productSize"
field-name="package.TestConstants.PRODUCT_SIZE"/>

And

     <parameter  name="productSize"   direction="in" java-type="long"
required="no"/>

And finally

  private long _productSize;

  public void setProductSize(long productSize)
 {
    _productSize = productSize;
 }

 public long getProductSize()
 {
    return _productSize;
 }


Constantly converting to strings is the way for other, lesser frameworks.
Tapestry allows you to do everything in real objects, methods and properties
... and real types.



>
> I have noticed if I change it to be a String instead of Long it works
> fine. Does this mean I have to use String or is this a bug??
>
>
>
> I would very much appreciate help on these questions.
>
> Thankyou, and thanks to Howard of course!
>
> Patrick.
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Tapestry-developer mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/tapestry-developer



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to