Mixing ExtJS in a JSP file

Get help with Spket IDE.
Post Reply
zbeeker
Posts: 5
Joined: Thu Sep 04, 2008 10:43 pm

Mixing ExtJS in a JSP file

Post by zbeeker » Thu Sep 04, 2008 11:04 pm

Is there any best practice(s) for mixing ExtJS, in general Javascript with JSP (or vice versa)? I have the following in a foo.jsp file which I don't think is too hard to read or maintain but it is annoying to see all the error squigglies... sort of defeats the purpose of having a javascript parser in the IDE.

Code: Select all

<script type="text/javascript">
// <![CDATA[

// ... excerpt, where the store data field is a javascript error ...

this.cboManufacturers = new Foo.GridComboBox({
	msgTarget: 'qtip',
	valueField: 'objectId',
	displayField: 'formattedName',
	gridRecordField: 'manufacturerOid',
	grid: this,
	typeAhead: true,
	mode: 'local',
	triggerAction: 'all',
	forceSelection: true,
	selectOnFocus: true,
	lazyRender: true,
	store: new Ext.data.SimpleStore({
		fields: ['objectId', 'formattedName'],
		sortInfo: {field: 'formattedName', direction: 'ASC'},
		data :[

		<web:dblist var="organizations" name="organizations-list" />
		<c:forEach items="${organizations}" var="item" varStatus="it">
			[
			'${item.objectId}',
			'<spring:escapeBody javaScriptEscape="true">${item.formattedName}</spring:escapeBody>'
			]<c:if test="${!it.last}">,</c:if>
		</c:forEach>
		]
	})
});

// ]]>
</script>

Thanks, Jim

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 05, 2008 10:07 am

Try open jsp file using other jsp editor, and using Alt+Shift+/ key for code assist for JavaScript. Spket IDE does not have a jsp editor yet.

zbeeker
Posts: 5
Joined: Thu Sep 04, 2008 10:43 pm

Post by zbeeker » Fri Sep 05, 2008 3:39 pm

Okay. Yes that works. It is a bit hard on my arithitic fingers. The problem is my JSP files are 90% or more Javascript that is why I open the JSP in the Spket editor. I guess I need to post to a different list to find best practices when mixing Javascript with JSP or how others approached ExtJS use w/ or w/in JSP.

I ran across a javascript plugin in maven that during compression deletes lines that begin with ';;;'. Is it possible to start and stop the Javasript parser? Like

var foo = new Array();
;;; // this would stop the parser
<c:forEach items="">
</c:forEach>
;;; // this would re-start the parser

Just thinking out loud. Doesn't matter either way to me... just having code assist for ExtJS is awesome enough.

Thanks, Jim

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 05, 2008 4:11 pm

Currently the parser will ignore the content between <? ?> and <% %>, but jspx/jsf tag are more complicated, kind like E4X, it is not that easy to achieved.

zbeeker
Posts: 5
Joined: Thu Sep 04, 2008 10:43 pm

Post by zbeeker » Fri Sep 05, 2008 5:08 pm

Okay, I tried the following but I think the "//" overrides the "<?".

Code: Select all

var store = new Ext.data.SimpleStore({
	fields: ['objectId', 'code'],
	data :[
	// <?
	<web:dblist var="tagIssuers" name="tagIssuers-list" />
	<c:forEach items="${tagIssuers}" var="item" varStatus="it">
		[
		'${item.objectId}',
		'<spring:escapeBody javaScriptEscape="true">${item.stamp}</spring:escapeBody>'
		]<c:if test="${!it.last}">,</c:if>
	</c:forEach>
	// ?>
	]
})

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Sat Sep 06, 2008 2:35 am

Hi, that is not overrides, because "//" is line comment, that means the characters in same line will be ignored.

zbeeker
Posts: 5
Joined: Thu Sep 04, 2008 10:43 pm

Post by zbeeker » Sat Sep 06, 2008 4:03 am

:D Of course // is for comments otherwise the <? would be flagged as a Javascript error and I'm trying to get rid of errors not create more. That is why I Javascript commented out the <? and ?>. I was hoping, "the parser will ignore the content between <? ?>" would be true and be true for -all- cases.

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Sat Sep 06, 2008 7:54 am

Isn't jspx/jsf should be valid XML file, and <? ?> in XML means Processing instructions, will the tag between <? ?> run correctly? you file should be XML first and the result is the javascript, so I don't think that '//' will help...

zbeeker
Posts: 5
Joined: Thu Sep 04, 2008 10:43 pm

Post by zbeeker » Sat Sep 06, 2008 3:17 pm

I don't think this thread is getting anywhere. All I want to do is hide the jspx/jsf from the Javascript parser. If it can't be done then it can't be done.

<? ?> is, as far as I know, for PHP instructions so for me it works since I'm not using PHP. On the server, the JSP interpreter just ignores it.

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Sun Sep 07, 2008 1:15 am

I will add a new option in next version to let you ignore the content between ///[ and ///], <? maybe not the right choice.

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Wed Sep 10, 2008 10:54 am

Version 1.6.15.2 released, two options were added in "Spket -> Editors -> JavaScript Editor" category, now you can using /*( )*/ to embed the server side tag, for examples, you can using /*-*/ to mark it as comment, and using /*[*/... /*]*/ to mark it as literal

Code: Select all

/*-*/<script type="text/javascript">/*-*/
var a = /*[*/ <whatever attr="value" /> /*]*/

nayasis
Posts: 5
Joined: Mon Jan 14, 2013 2:50 pm

Re: Mixing ExtJS in a JSP file

Post by nayasis » Mon Jan 14, 2013 2:55 pm

You're very genius ! and great man !

It's very complex to inject your parser to JSP editor in eclipse. But, you suggest another solution to satisfy other developer.

( I wonder how much they are appreciate to you. But !! at least.. I sincerely respect you ! )

Have a good day ! Eric !

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest