We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

tapestry question on jwcid

bhomass
bhomass asked
on
Medium Priority
707 Views
Last Modified: 2013-11-24
any tapestry experts?

what is this format
         jwcid="table@contrib:Table"
based on?
Comment
Watch Question

Commented:
The jwcid attribute is tapestry-specific. It means that you are defining an instance of a Table component, which comes from the contrib package, and you are giving it the reference id 'table'. You can reference the component from elsewhere (for example to iterate through the rows of the table) using your 'table' id.

Author

Commented:
I don't think you got my question. I know all about the jwcid itself.

the question is about the FORMAT of "table@contrib:Table". seems like a strange notation to me. how are you suppose to interpret the @ and :?

Commented:
I think of '@' as 'instance-of' and ':' as a qualifier to avoid name clashes. (I should have said 'library' instead of 'package' in my previous posting.)

So jwcid="table@contrib:Table" reads as "jwcid is 'table', which is an instance of contrib:Table"

I haven't thought about it more than that - it's just a notation.

Author

Commented:
and what does contrib:Table mean in terms of designated a specific java class?

I know its just a notation, and java is just a language. how would you apply such notation if you don't know the rules?

I am particularly interested in the foundation of this notation. which standard is at its base?

Commented:
You have to look at the component specification to discover the corresponding java class. If you take a look inside the tapestry-contrib-<version>.jar you find the Java class named in the Table.jwc file:

<component-specification class="org.apache.tapestry.contrib.table.components.Table"
      allow-body="yes" allow-informal-parameters="yes">
...
</component-specification>

You're going to run into difficulties applying a notation if you don't know its syntax and semantics, although you might have some (perhaps limited) success by copying the pattern of some working code.

I doubt that this notation adheres to any standard external to Tapestry. I had a scan of the WebObjects manuals, as the component-based approach of Tapestry is, I believe, loosely derived from WebObjects, but I didn't see anything resembling this notation.

Author

Commented:
I also already know that this particular jwcid points to the contributed Table.Component class.

here is my problem. I like to create my own components intead of using those included in Tapestry. without knowing how the name convention gets applied, how do I decide what package, class name, and jwcid format to use?

if someone knows the rules, please enlighten me.

Commented:
Sounds like you are looking for a style guide.

For the class name, use whatever choice of class you would use in any project. This is not affected by the use of Tapestry. For example, many organisations stipulate allowed choices of Java package based on the organisation's URL and departmental or project structure, so this is often in a company style guide.

For the package/library, it depends on how you see the reuse of your libraries. Which parts are reusable and which parts are likely to be reused? How much effort do you want to spend in making sure they are independently deployable? Such issues arise in many contexts - not just in Tapestry. This runs far deeper than a question about a jwcid format! Usually your manager or company strategy will define how much effort to spend here.

What jwcid format to use? Whether to use fully qualified components in the HTML templates, anonymous components, page classes, annotations etc. is all a matter of personal preference. The "trend" (judging by the latest versions of Tapestry) is to pack as much as possible into the Java class via Java 1.5 annotations.

Author

Commented:
I think you are getting further and further afield as we go on.

Let me try rephrase:

we know that jwcic="table@contrib:Table" maps to org.apache.tapestry.contrib.table.components.Table.

so once I developed a class com.mycompany.myproject.MyClass, what do I put for jwcid to map to this clas?

Commented:
Your component is defined in a .jwc file
If it is called MyClass.jwc then you make an entry in your .application file to declare the component:

<component-type type="MyClass" specification-path="MyClass.jwc"/>

and refer to the component using @MyClass


Author

Commented:
ok, now we are hitting it.

what about the library name "contrib" used in contrib:Table. how would I create a cutom lib for my html's to reference?

I have increased the points for the efforts and results shown.
Commented:
A custom library is just another JAR file. The JAR file contains a .library file that has a library-specification:

<library-specification>
  <component-type type="MyClass" specification-path="MyClass.jwc"/>
  ...
</library-specification>

The library is then referenced from your .application file:

<library id="myLib" specification-path="/com/foo/components/MyComponents.library"/>

Here, the specification-path is the path to the library specification within the JAR file.
Once you have given the library the id "myLib", you should refer to components from that library using that prefix, as in @myLib:MyClass

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
you truly are an expert on this subject.

Thanks for all the info, which really helps to speed ahead.

Commented:
Thanks - Glad I was able to help!

Author

Commented:
if I can ask one more thing. where can I find the references to your answers?

Commented:
If you're serious about using Tapestry, I recommend 'Enjoying Web Development with Tapestry' by Kent Tong Ka Iok ("Tong's book"). You can buy it from Amazon, or buy a PDF version online. See http://www.agileskills2.org/EWDT/

(I'm not connected in any way with the author - I just think it is a very practical book and much more useful than 'Tapestry in Action', published by Manning)

Other than that, I use the tapestry documentation at http://tapestry.apache.org/ and the Tapestry forums at http://www.tapestryforums.com/

Author

Commented:
did you get the details concerning the libray tag in the .application file from the tapestry website or from the book you recommended?

It will help me locate the references on the web if they are there at all.

Commented:
In Tong's book, there is a chapter called 'Creating Custom Components' that should answer your questions (see from p. 155 in the Tapestry 4 edition)

The DTD specs might also be useful: http://tapestry.apache.org/tapestry4/UsersGuide/spec.html
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.