"with the target attribute you do not type in the String literal that represents the name under which the attribute was bound to the page, scope, etc. The "target" attribute must have a value that resolves the real thing."
-Head First Bible, Chapter 9 verse 446
So it must be an EL expression, scripting expression, jsp:attribute
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
Thanks Biba!
What's "jsp:attribute", a standard action? i couldn't find it even in jsp spec. :roll:
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
sorry, i do find it after navigating the Spec "slowly", wow! "Automatic" searching "jsp:attribute" in adobe reader leads to nothing.
Niranjan Deshpande
Ranch Hand
Joined: Oct 16, 2005
Posts: 1277
posted
0
consider the cas where you hava custom tag called "myAdvice" and it has to mandatory attibutes called "taste" and "colour". Suppose that it has declared <body-content>empty</body-content>. now consider the following code -
its clear from the above example that, jsp:sttribute is a way to set the attributes of your tag, as a BODY, even thoug your tag cant have a body
got it ??
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ] Performance is a compulsion, not a option, if my existence is to be justified.
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
refactor c:set below,
Got that exception again...
Stary Kapec
Ranch Hand
Joined: Dec 04, 2005
Posts: 81
posted
0
I am also very confused.
It compiles and works.
It compiles and works. But
It does not work! Why? I get an exception: org.apache.jasper.JasperException: Invalid property in <set>: "p"
Biba Basnetti
Greenhorn
Joined: Oct 09, 2006
Posts: 25
posted
0
I guess Head First was wrong about this.
It seems illegal to set <c:set> tag's TARGET attribute with <jsp:attribute> It doesn't work if you put EL or a scriplet inside the jsp:attribute body. It makes sense though because if you can't even set the target with a string literal variable that has a reference to an object why should you be able to use <jsp:attribute>? Isn't the body of the jsp:attribute tag going to be evaluated to a string literal too?
So you put the EL ${myBean} in the body of jsp:attribute and assign it to the target attribute, you are assigning "mybeans.MyBean@13b9fae"
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
The "target" attribute may accept ELed/expressed value when "rtexprvalue" is turned on in tld. "Unforturnately" here it IS the case.
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
let's explore how tag handler classes use setter to deal with attributes.
tag form 1: attribute="name" converted to: setAttribute(name), inside the setter, we can code below,
{ name instanceof String?this.value=getValue(name):throw new Exception(); }
tag form 2: attribute="${name}" converted to: setAttribute(value=getValue(name)), inside the setter, we can code below,
{ this.value=value; }
In the handlers we can continue set/get properties of value normally if it is bean object, otherwise an exception is thrown. [ January 12, 2007: Message edited by: Bob CHOI ]
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
Go on with "dynamic" attribute a little bit below
tag form 3: dynaAttrName="value" converted to: javax.servlet.jsp.tagext.DynamicAttributes:setAttribute(namespace,dynaAttrName,value), inside the setter, we can code below,
tag form 4: dynaAttrName="${name}" converted to: javax.servlet.jsp.tagext.DynamicAttributes:setAttribute(namespace,dynaAttrName,value=getValue(name)), inside the setter, we can code similar to above.
Stary Kapec
Ranch Hand
Joined: Dec 04, 2005
Posts: 81
posted
0
Hi, Bob, I hardly follow your explanations. To put it simple <jsp : attribute > element has its use only with attributes which type is String. Am I right? Don't you think it is not very useful then?
I observed another strange behaviour regarding attribute standard action.
It works, But:
It does not! org.apache.jasper.JasperException: <h3>Validation error messages from TagLibraryValidator for c in /SimplePage.jsp</h3><p>18: Encountered illegal body of tag "c:set" tag, given its attributes.</p>
[ January 14, 2007: Message edited by: Jasiek Motyka ] [ January 14, 2007: Message edited by: Jasiek Motyka ]
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
Hi Jasiek
jsp:attribute might declare not accepting ELed stuff providing that it had used declarative "rtexprvalue=false".
Howerver the problem on the 2nd code snippet seems strange to me, too.
Bob CHOI
Ranch Hand
Joined: Nov 10, 2006
Posts: 127
posted
0
Hi Jasiek
Sorry, i was mistaked about "rtexprvlaue" - it's all about attribute. The behavior on both code snippets might actually depend on "body-content" setting on c:set and jsp:attribute.
"body-content" has four optional values: - empty - scriptless - jsp - tagdependant
Therefore, "body-content=tagdependant" could cause them to act "irregually" till we find out how the tag handlers work accordingly.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.