开发者

Can I use a *.tag from another *.tag file in the same /WEB-INF/tags folder?

I am trying to refactor my JSP code so that a small conditional test condition gets reused through a *.tag file.

There are some big parts of my UI that depend on the value of a two-state property of an object present in the request. Let's say the property is 'gender' and the object is of type Person.

Like I said, I would like to simplify & centralize the test on the gender property using a tag. For开发者_运维技巧 this purpose, I created two tag files:

/WEB-INF/tags/if-male.tag
/WEB-INF/tags/if-female.tag

Now, I have another tiny spot that gets repeated in all over my application; let's say is the salutation to my site user. With this idea, I created a tag like this:

/WEB-INF/tags/salutation.tag

As you can imagine, I am trying to use the if-male/if-female test within the salutation.tag file to output 'Mrs.' or 'Mr.' like this:

<%@ tag body-content="empty" %>
<%@ taglib prefix="g" uri="/WEB-INF/tags" %>
<g:if-male> Mr. </g:if-male>
<g:if-female> Mrs. </g:if-female>

Is the use of the if-male/if-female tags legal within the salutation.tag file?

I have tried with such arrangement, but it looks like the JDeveloper 10.1.3.4 compiler gets confused and cannot deal with the salutation.tag tag invoking the other two tags in the same 'library' (folder under /WEB-INF/tags).

The reference works perfectly in Jetty 6 and it looks like it works as well if I deploy the application to OC4J directly without relying on JDeveloper to pre-compile all my JSPs.

I hope someone can shed some light on this.

Thanks,

YJ


Including tag declarations inside of other custom tags--I do this all the time and with syntax matching yours.


This is absolutely legal, and is part of the attraction of tag files.

If JDeveloper doesn't like it, that's JDeveloper's problem. You should consider using a modern IDE (eclipse, netbeans, intellij) instead, JDeveloper's time (if it ever had one) is long gone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜