You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Marcus <mv...@gmail.com> on 2008/05/29 01:45:52 UTC

T5 Creating a Library of Custom Components

Hi,

I'm trying to create a T5 library using Eclipse, but...   :(
Here are my steps and codes.


- New Java Project:   t5lib
- Compiler compliance level is set to 5

src
src/pub/t5lib
src/pub/t5lib/LibraryModule.java
src/pub/t5lib/components
src/pub/t5lib/components/MyComponent.java  (don't have a template)
src/MANIFEST.MF

- In Eclipse: Project Properties: Java Build Path: Libraries: Add JAR's:
tapestry-core-5.0.11.jar
tapestry-ioc-5.0.11.jar

LibraryModule.java:
---------------------------
package pub.t5lib;
import org.apache.tapestry.ioc.Configuration;
import org.apache.tapestry.services.LibraryMapping;
public class LibraryModule {
    public static void contributeComponentClassResolver(
            Configuration<LibraryMapping> configuration) {
        configuration.add(new LibraryMapping("t5lib", "pub.t5lib"));
    }
}

MyComponent.java:  (just a simple output component)
----------------------------
package pub.t5lib.components;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.ioc.annotations.Inject;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
public class MyComponent {
    @Parameter(required = true)
    private Object _value;

    @Parameter("componentResources.elementName")
    private String _elementName;

    @Inject
    private ComponentResources _resources;

    boolean beginRender(MarkupWriter writer) throws Exception {
         formatted = ((Format) _format).format(_value);
         if (InternalUtils.isNonBlank(formatted)) {
            if (_elementName != null) {
                writer.element(_elementName);
                _resources.renderInformalParameters(writer);
            }
            writer.write(formatted);
            if (_elementName != null)
                writer.end();
        }
        return false;
    }
}

MANIFEST.MF:
----------------------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.6.0_02-b06 (Sun Microsystems Inc.)
Tapestry-Module-Classes: pub.t5lib.LibraryModule


PS: last line of manifest ends with a carriage return.

- in Eclipse: Project Explorer: Export...
- JAR file
- None resources select on t5lib root, just src sub-folder, checked "Export
generated class...",  JAR file: C:\t5lib-0.0.1.jar , checked "Compress..."
- only checked "Build project..."
- Use existing manifest from workspace, /t5lib/MANIFEST.MF  <Finish>

- just put the library file (t5lib-0.0.1.jar) into the WEB-INF/lib subfolder
of another project (a new T5.0.11 project, just created with maven, with
only Index.tml)

- Trying to use a component in Index.tml, like this:
<t:t5lib.MyComponent  t:value="currentTime" />
or like this:
<span t:type="t5lib/MyComponent"  t:value="currentTime" />

ERROR
Unable to resolve 't5lib/MyComponent' to a component class name. Available
component types: ActionLink, Any, BeanDisplay, BeanEditForm, BeanEditor,
Checkbox, DateField, Delegate, Errors, EventLink, ExceptionDisplay, Form,
FormFragment, FormInjector, Grid, GridCell, GridColumns, GridPager,
GridRows, If, Label, Loop, Output, OutputRaw, PageLink, Palette,
PasswordField, PropertyDisplay, PropertyEditor, Radio, RadioGroup,
RenderObject, Select, Submit, SubmitNotifier, TextArea, TextField,
TextOutput, Unless, Zone.
Stack trace

   -
   org.apache.tapestry.internal.services.ComponentClassResolverImpl$5.invoke(ComponentClassResolverImpl.java:446)
   -
   org.apache.tapestry.internal.services.ComponentClassResolverImpl$5.invoke(ComponentClassResolverImpl.java:442)
   -
   org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
   -
   org.apache.tapestry.internal.services.ComponentClassResolverImpl.resolveComponentTypeToClassName(ComponentClassResolverImpl.java:440)
   -
   org.apache.tapestry.internal.services.PageElementFactoryImpl.newComponentElement(PageElementFactoryImpl.java:202)
   -
   org.apache.tapestry.internal.services.PageLoaderProcessor.startComponent(PageLoaderProcessor.java:655)
   -
   org.apache.tapestry.internal.services.PageLoaderProcessor.loadTemplateForComponent(PageLoaderProcessor.java:500)
   -
   org.apache.tapestry.internal.services.PageLoaderProcessor.workComponentQueue(PageLoaderProcessor.java:807)
   -
   org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(PageLoaderProcessor.java:392)
   -
   org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(PageLoaderImpl.java:59)
   -
   org.apache.tapestry.internal.services.PagePoolCache.checkout(PagePoolCache.java:188)
   -
   org.apache.tapestry.internal.services.PagePoolImpl.checkout(PagePoolImpl.java:107)
   -
   org.apache.tapestry.internal.services.RequestPageCacheImpl.get(RequestPageCacheImpl.java:43)
   -
   org.apache.tapestry.internal.services.RequestSecurityManagerImpl.checkForInsecureRequest(RequestSecurityManagerImpl.java:59)
   -
   org.apache.tapestry.services.TapestryModule$29.handle(TapestryModule.java:1605)
   -
   org.apache.tapestry.internal.services.PageRenderDispatcher.process(PageRenderDispatcher.java:97)
   -
   org.apache.tapestry.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:83)
   -
   org.apache.tapestry.services.TapestryModule$13.service(TapestryModule.java:944)
   - org.exemplo.t5011.services.AppModule$1.service(AppModule.java:98)
   -
   org.apache.tapestry.internal.services.LocalizationFilter.service(LocalizationFilter.java:42)
   -
   org.apache.tapestry.services.TapestryModule$3.service(TapestryModule.java:553)
   -
   org.apache.tapestry.services.TapestryModule$2.service(TapestryModule.java:520)
   -
   org.apache.tapestry.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:79)
   -
   org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:93)
   -
   org.apache.tapestry.internal.services.CheckForUpdatesFilter$2.invoke(CheckForUpdatesFilter.java:84)
   -
   org.apache.tapestry.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:77)
   -
   org.apache.tapestry.internal.services.CheckForUpdatesFilter.service(CheckForUpdatesFilter.java:106)
   -
   org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:924)
   -
   org.apache.tapestry.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
   - org.apache.tapestry.TapestryFilter.doFilter(TapestryFilter.java:168)
   -
   org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
   -
   org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
   -
   org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
   - org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
   -
   org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
   - org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
   - org.mortbay.http.HttpServer.service(HttpServer.java:909)
   - org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
   - org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
   - org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
   -
   org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245)
   - org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
   - org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)



Thank in advance,

Marcus

Re: T5 Creating a Library of Custom Components

Posted by Jesper Zedlitz <jz...@informatik.uni-kiel.de>.
Marcus wrote:
> I'm trying to create a T5 library using Eclipse, but...   :(
> 
I had a similar problem. Do you use Maven2 for dependency handling? The
Maven Eclipse plugin will use the Eclipse project (containing the
component) instead of the jar file. 
If you close the Eclipse project containing the component the plugin is
forced to use the jar file (that contains the correct MANIFEST.MF).

Jesper

-- 
Jesper Zedlitz                   Dept. for Computer Science, CAU of Kiel
Room 1108                        Communication Systems Research Group
                                 Phone:    +49-(0)431-880-7279
Christian-Albrechts-Platz 4      Fax:      +49-(0)431-880-7615
24098 Kiel - Germany             jze@informatik.uni-kiel.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 Creating a Library of Custom Components

Posted by Marcus <mv...@gmail.com>.
Hi Thiago,

- MANIFEST.MF was extracted from JAR and checked, file is ok
- Try putting JAR in project build path.

same error   :(

Marcus

Re: T5 Creating a Library of Custom Components

Posted by Thiago HP <th...@gmail.com>.
On 5/28/08, Marcus <mv...@gmail.com> wrote:
> Hi Thiago,
>
>  You are right, LibraryModule was not loaded.

Hi!

Check your JAR's MANIFEST.MF. If it is OK, try putting your JAR in the
classpath through Eclipse project settings instead of just dropping
your JAR in WEB-INF/lib.

-- 
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 Creating a Library of Custom Components

Posted by Marcus <mv...@gmail.com>.
Hi Thiago,

You are right, LibraryModule was not loaded.

generated JAR:

META-INF
META-INF/MANIFEST.MF
pub
pub/t5lib
pub/t5lib/LibraryModule.class
pub/t5lib/components
pub/t5lib/components/MyComponent.class

any idea?

Thanks,

Marcus

Re: T5 Creating a Library of Custom Components

Posted by Thiago HP <th...@gmail.com>.
It looks like your LibraryModule was not loaded. To ensure it is, put
a System.out.println("Module loaded!") in your
contributeComponentClassResolver() method. Also check the generated
JAR to ensure everything is in the proper place.

-- 
Thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org