JSP Tag syntax and use

S

SirHaplo

Hello guys,
i'm developing a JSP page, starting from an example.

I'm using JPivot, a tag library for rendering OLAP results.
Everything works well, but i need a bit of customization.

The example code is like that :

<jp:mondrianQuery id="queryGuaber"
jdbcDriver="com.mysql.jdbc.Driver"
jdbcUrl="jdbc:mysql://localhost/TMS
catalogUri="/Guaber.xml">
select {Referenze} on columns, {Mercato} on rows from
Rilevazioni
</jp:mondrianQuery>
<jp:table id="table01" query="#{queryGuaber}"/>

As you can see in tag tag <jp:table it use query="#{queryGuaber}. What
is that syntax ? I mean the # and the bracket.

In another tag it use to get a property :
"#{table01.extensions.drillMember.enabled}"

I want to know if I can use those objects in "normal" JSP ?
Like that
<%
out.println(table01.extensions.drillMember.enabled);
%>
This give me an error.

Thanks in advice.
A little JSP noob
 
L

Lew

SirHaplo said:
Hello guys,
i'm developing a JSP page, starting from an example.

I'm using JPivot, a tag library for rendering OLAP results.
Everything works well, but i need a bit of customization.

JSTL also sports database tags.
<jp:table id="table01" query="#{queryGuaber}"/>

As you can see in tag tag <jp:table it use query="#{queryGuaber}. What
is that syntax ? I mean the # and the bracket.

Are you sure the character is '#' and not '$'?
<%
out.println(table01.extensions.drillMember.enabled);
%>

You absolutely never need an 'out.println' in JSP. Just put the expression in
the HTML, or use <c:eek:ut ... />

<p>
${table01.extensions.drillMember.enabled}
</p>

Furthermore, the "." notation in your Java scriptlet implies that you used
public instance members, a bad practice. It is usually better to provide
accessor methods:
// Java, not EL
out.println( table01.getExtensions() [drillMember].isEnabled() );

But of course, the EL in JSP is preferable.

By its nature, a JSP translate all its HTML into "out.println()" calls, so you
don't have to.

- Lew
 
S

SirHaplo

JSTL also sports database tags.

Of course, but with JPivot i can visually build MDX querys and render
the results.
This is very useful for our customers.
Are you sure the character is '#' and not '$'?

Absolutely sure.
You absolutely never need an 'out.println' in JSP. Just put the expression in
the HTML, or use <c:eek:ut ... />

<p>
${table01.extensions.drillMember.enabled}
</p>

Thanks a lot for the advice, but i used out.printl as an example ;)

Furthermore, the "." notation in your Java scriptlet implies that you used
public instance members, a bad practice. It is usually better to provide
accessor methods:
// Java, not EL
out.println( table01.getExtensions() [drillMember].isEnabled() );

But of course, the EL in JSP is preferable.

This is a good advice, but the code isn't mine. In future if i will
write my own Tag Library i will follow your rule.

Finally, no one know the meaning of #{} ?

Thanks a lot
 
L

Lew

Lew said:
Furthermore, the "." notation in your Java scriptlet implies that you used
public instance members, a bad practice. It is usually better to provide
accessor methods:
// Java, not EL
out.println( table01.getExtensions() [drillMember].isEnabled() );

But of course, the EL in JSP is preferable.
This is a good advice, but the code isn't mine. In future if i will
write my own Tag Library i will follow your rule.

This is not related to tag libraries but Expression Language (EL) and regular
Java syntax.

The expression "table01.extensions.drillMember.enabled" in Java scriptlet will
only compile if the member variables are public, which is bad practice.

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top