• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What are <variable> & <name-from-attribute> tags in the TLD??

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here's a question from a mock exam of enthuware :

Assuming that the tag library shown in the exhibit is imported with the prefix 'item'. Which custom tag invocation outputs the contents of the variable exported in the 'price' tag?
The options are :

  • <item:price itemcode="IT001" />
    ${var}
  • <item:price itemcode="IT001" var='cost' >
    ${cost}
    </item:price>
  • <item:price itemcode="IT001" >
    ${var}
    </item:price>
  • <item:price itemcode="IT001" var='cost' />
    ${cost}
  • <item:price itemcode="IT001" var='cost'>
    <%=cost%>
    </item:price>
  • <%=cost%>
    <item:price itemcode="IT001" var='cost'></item:price>


  • And here is the exhibit for this question :

    <?xml version="1.0" encoding="UTF-8" ?>
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance:
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    version="2.0">
    <tlib-version>1.0</tlib-version>
    <short-name>item</short-name>
    <uri>http://abc.com/tld/item.tld<uri>;
    <tag>
    <name>price</name>
    <tag-class>com.abc.PriceTag</tag-class>
    <body-content>scriptless</body-content>
    <variable>
    <name-from-attribute>var</name-from-attribute>
    <scope>NESTED</scope>
    </variable>

    <attribute>
    <name>itemcode</name>
    <required>true</required>
    <rtexprvalue>false</rtexprvalue>
    <attribute>
    <tag>
    <taglib>


    Can anyone explain me this <variable> & <name-from-attribute> tag??
    I didn't come across these tags while reading HFSJ. Perhaps I might have missed something...
     
    Sourin K. Sen
    Ranch Hand
    Posts: 86
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Anyone please??
     
    Ranch Hand
    Posts: 324
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hello,

    What is the correct options??? I am not clear but i guess <variable> tag is specified here is used to expose the value of a attribute specified..

    I am not sure.... anyone please clear this doubt



    thanks in advance
     
    Sourin K. Sen
    Ranch Hand
    Posts: 86
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Poonam Agarwal wrote:What is the correct options???


    The correct option is :

    <item:price itemcode="IT001" var='cost' >
    ${cost}
    </item:price>


    But my questions are :
    1. Are all of the elements and sub-elements of a TLD file are covered in the exam?
    2. Where to get proper info on these elements apart from the JSP Spec (its kinda messy and hard to read)
     
    Poonam Agarwal
    Ranch Hand
    Posts: 324
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    totaly agree with you.... JSP spec have the details of these tag but its very hard to get it... I tried to mugging but won't help


     
    Poonam Agarwal
    Ranch Hand
    Posts: 324
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    anybody else??
     
    Poonam Agarwal
    Ranch Hand
    Posts: 324
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hello Sourin,

    I just seen an example showing the use of <variable> tag in the TLD. I hope this will help you to clera your doubts , atleast little bit

    This question is from Enthuware mock

    You are using a tag library with prefix "generator", which supports a tag named "random". This tag generates a random number and sets it to a variable named "value". Which of the following will output this value in the page?

    1. <generator:random>value</generator:random>
    2. <generator:random><%=value%></generator:random>
    3. <generator:random><% int value;%> <%=value%></generator:random>
    4. None of the above.

    the correct option is 2. the explaination given is

    The variables that are set by the custom tag are defined in customtag TagExtraInfo class. For example, in this case, the ExtraInfo impl for this tag should return an array of VariableInfo objects, an object of which will be same as:

    new VariableInfo("value", "String", true, VariableInfo.NESTED);

    true => a new variable 'value' will be declared.

    NESTED => Between the start tag and the end tag.

    Another way to specify that a custom tag exposes a variable to the JSP page is through the <tag> element of the TLD. For example, the TLD for the above tag may contain:

    <tag>
    ...
    <variable>
    <name-given>value</name-give>
    <variable-class>java.lang.Double</variable-class>
    <scope>AT_BEGIN</scope>
    </variable>
    </tag>
    </tag>

    I guess you can ignore some of initial details about classes and all.

     
    Sourin K. Sen
    Ranch Hand
    Posts: 86
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks a lot Poonam. That clears up the issue of how to use it and why to use it. But still one question is left ( I haven't gone through the SCWCD Exam Spec thoroughly), is it covered on the exam?

    What else is covered on the exam which is not covered by HFSJ?

    I dont have much time left with me as I am going to give the exam in a few days time and so it would be very helpful for me if someone can list out the things that haven't been covered by HFSJ but are there for the exam.

    Thanks a lot in advance.
     
    Poonam Agarwal
    Ranch Hand
    Posts: 324
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sourin,

    Don't worry. there is nothing that HFSJ dosen't cover. It meant to clear the SCWCD with flying colors.

    I am sure you don't need anyhting else if you cover that book completely. you will cleat the exam very easily. Just refer the API for important method signataure and related specification.



    All the VERY BEST for your exam
     
    rubbery bacon. crispy tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic