Skip to main content

${object.property} not working in Widget jsp tag

5 replies [Last post]
chandanahuja
Offline
Joined: 2007-11-20

Hello All ,
I am new to jMaki, and using it i am trying to put a yahoo Datatable
widget in a JSP file.

I am using JBoss , server .

Here is the relevant part of my JSP file

..........................................

<%

cols.clear();
cols.addColumn("title", "Title");
cols.addColumn("author", "Author");
cols.addColumn("isbn", "ISBN");
cols.addColumn("description", "Description");
%>

.
..........................................

Pls. note that i am using a bean to define the columns of the datatable,
by using the mechanism "${cols.json}".(cols.getjson() returns the "cols" state as json String )

BUT, the problem is that the datatable is not rendered when the page is rendered ,
here is the part of the html generated for the jsp...........................

....................................................

jmaki.addWidget({widgetDir:'http://localhost:8080/searchportlet/resources/yahoo/dataTable',value:{
rows : [
] , columns : ${cols.json}
},args:{ caption : 'Test Table', paginated : true, paginator : {rowsPerPage: 5, currentPage:1, pageLinks:5, dropdownOptions: [5,10,25,50,100,500], pageLinksStart:1}},uuid:'yahoo_dataTable8',name:'yahoo.dataTable',sourceURL:'http://localhost:8080/searchportlet/jsp/search_form.jsp?uP_fname=SearchPortlet'});
..........................................

In the rendered html pls note that the value of "Columns" defined in args is not
coming from the bean "cols" , but is coming the same way it was written in JSP ie. ${cols.json} . I think this is the possible reason of datatable not rendering.

I'd be thankful to the members if any help is provided as to what can be the reason for this behaviour and how to rectify it .

Best Regards ,
Chandan Ahuja

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chandanahuja
Offline
Joined: 2007-11-20

Thanks Greg for your guidance ,I have figured out the real cause of problem....
actually i needed to add a JSP page directive to enable EL in JSP page when i did that it started working.

This is what needs to be added on the top of JSP ...

<%@ page isELIgnored="false"%>

Thanks and Best Regards,
Chandan Ahuja

gmurray71
Offline
Joined: 2003-07-31

So cool! Glad to see you got things working. It's funny were both posting at the same time ;-)

gmurray71
Offline
Joined: 2003-07-31

Hi Chandan,

I'm able to get the ${object.property} to work fine in both Tomcat 6 and Glassfish V2 both of which are JavaEE 5 compliant. Here is my sample code:

<%
request.setAttribute("greg", "TITILE");

%>
value="{columns : [
{ label : '${greg}', id : 'title'},
{ label :'Author', id : 'author'},
{ label : 'ISBN', id : 'isbn'},
{ label : 'Description', id : 'description'}
],
rows : [
{ title : 'Book Title 1', author : 'Author 1', isbn: '4412', description : 'A Some long description'},
{ id : 'bar', title : 'Book Title 2', author : 'Author 2', isbn : '4412', description : 'A Some long description'}
]
}" />

This is pretty much the same as what you are doing right?

The ${greg} portion is getting replaced correctly.

I believe there can only be three potential problems here:

1) The version of JBoss you are using does not support the JSP Expression Language replacements. What you are trying to do requires J2EE 1.4 or better. If you are on a current version of JBoss check to make sure your web.xml is referring to the J2EE 1.4 or Java EE 5 schemas as you may be running in a compatibility mode for J2EE 1.3.

2) The beans are returning the correct data format.

3) You are using a super old version of jMaki. In early version (maybe .7 and before) we didn't allow for EL expressions in the value attribute if memory serves.

I strongly feel #1 or #3 are your issue.

You can test my assumption on #1 being the problem by trying my simple sample.

I hope this helps.

-Greg

chandanahuja
Offline
Joined: 2007-11-20

Dear Greg ,

Thanks for your detailed reply .

The sample given by you is not working properly on my sever , it again shows me the columns head as "${greg}" as it is , and not it value('TITLE') .

--About J2EE Version of my server - I am using JBoss 4.2 which as per its documentation is compatible with J2EE 1.4 codebase. Pls let me know how to find out the J2EE version from web.xml dtd (as mentioned by you ), if that can help .

--About jMaki Version - the jmaki-uncompressed.js shows its version as 1.0...

.......................................
function Jmaki() {

var _jmaki = this;

this.version = '1.0';

...................................

-- About the value in bean -- I printed the value on JSP page it shows me the correct output , i think .

[{"label":"Title","id":"title"},{"label":"Author","id":"author"},{"label":"ISBN","id":"isbn"},{"label":"Description","id":"description"}]

I'd be thankful to you if you can help me more in this regard.

Best Regards,
Chandan Ahuja

gmurray71
Offline
Joined: 2003-07-31

Hi,

The rows data format is ok but it will give you problems when you get the expression language working because you will have double quotes within double quotes.

Try using single quotes or escape the quotes. If you can I suggest single quotes. In order to do this you can use some code we wrote that uses the JSON Java API to generate the content. There is a blog posting here about it:

http://rwatsh.blogspot.com/2007/06/working-with-jmaki.html

As for the web.xml you will need to use a schema as the DTDs were depreciated and using htem can cause you to revert back to J2EE 1.3.

Here is the schema header you should see.

If this doesn't work we will have to look around and see if JBoss supports EL expressions in attributes.

-Greg