Auto completion of bean properties in EL

In my JSP files I put a bean into the page scope by using a scriptlet something to the effect of:
${bean.title} etc. This works fine. As you can see, I need to call one of BeanClass's member methods with parameters, so I have to do this as a scriptlet. The only problem with this strategy is that "${bean.title}" has the word "bean" highlighted yellow in intellij. When I include a line like the following to the top of the page, idea acts very intelligently, and does auto completion and error highlighting: ]]>
Unfortunately it won't compile, saying that the page has a duplicate variable.

So my question is this: is there any way to make idea function well that won't prohibit the page from compiling?

Thank you.

12 comments
Comment actions Permalink

Hm, in recent EAP builds there is a quickfix (alt-enter) that you can use to add a
comment "annotation" in the jsp that tells Idea about the type of the el variable.
Don't know what build you are using, though...

Stephen Cilley wrote:

In my JSP files I put a bean into the page scope by using a scriptlet something to the effect of:
<%
BeanClass bean = new BeanClass();
bean.process(request, response);
pageContext.setAttribute("bean", bean);
%>

<html>
<head>
<title>${bean.title}</title>

etc.

This works fine. As you can see, I need to call one of BeanClass's member methods with parameters, so I have to do this as a scriptlet.
The only problem with this strategy is that "${bean.title}" has the word "bean" highlighted yellow in intellij. When I include a line like the following to the top of the page, idea acts very intelligently, and does auto completion and error highlighting:
<jsp:useBean id="bean" scope="page" />
Unfortunately it won't compile, saying that the page has a duplicate variable.

So my question is this: is there any way to make idea function well that won't prohibit the page from compiling?

Thank you.

0
Comment actions Permalink

I'm using build 6189. I don't know what EAP is. Alt-enter doesn't do anything in Idea.

Thank you.

0
Comment actions Permalink

Sorry, EAP is the Idea "Early Access Programm".
The recent versions are quite stable as most major feature for the next version are
already done. (Of course there could always still be gross bugs, so use with care
- you do have your sources in VCS anyway, do you?
If you want to try it - download is at
http://www.jetbrains.net/confluence/display/IDEADEV/Selena+EAP
There are lots of overall enhancements.
Beware: Idea's project format has changed, so backup your project files, because
currently Idea migrates them without warning.

In recent EAP builds, if there's an error about unknown bean, there is a quickfix
that you can invoke with alt-enter when the caret is on the yellow warning.

Stephen Cilley wrote:

I'm using build 6189. I don't know what EAP is. Alt-enter doesn't do anything in Idea.

Thank you.

0
Comment actions Permalink

Cool, thanks.
I've just used the newest build for about 45 minutes, and the workaround works fine. It would be better if there were some sort of automatic detection, but this works fine.
Thank you.

0
Comment actions Permalink

IDEA will recognize variable directly from 'pageContext.setAttribute'

Stephen Cilley wrote:

Cool, thanks.
I've just used the newest build for about 45 minutes, and the workaround works fine. It would be better if there were some sort of automatic detection, but this works fine.
Thank you.


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Any idea when it will do that? Or is it supposed to do that already? In which case I've still got a problem.

0
Comment actions Permalink

In next Selena EAP build

Stephen Cilley wrote:

Any idea when it will do that? Or is it supposed to do that already? In which case I've still got a problem.


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

I downloaded 7269, and now, with or without the comment declaration, all member properties are highlighted as warnings.
Which is to say in the following, "property" is highlighted as a warning:
${bean.property}
with the message cannot resolve property or method property (dynamic property?) more...
The bean is placed in the page context exactly as before.

0
Comment actions Permalink

IDEA seems not recognized type of 'bean' variable, please, check
that you do not have problems with module configuration.

Stephen Cilley wrote:

I downloaded 7269, and now, with or without the comment declaration, all member properties are highlighted as warnings.
Which is to say in the following, "property" is highlighted as a warning:
${bean.property}
with the message cannot resolve property or method property (dynamic property?) more...
The bean is placed in the page context exactly as before.


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

I don't understand, what am I checking them for? I have a variable of class "xyz" that has bean style properties, I'm placing that bean in the pageContext using the servlet call. Though the fact that the variable "xyz" is in the PC seems to be registered (given that "xyz" doesn't get highlighted) Idea doesn't seem to know what type the variable is. What could cause this? How should I look to fix it?

0
Comment actions Permalink

JDK may become unassigned when opening IDEA 6 project with Selena.
Following code is green for me:
<%
String s = "";
pageContext.setAttribute ("aaa", s);
%>
${aaa.bytes}

Stephen Cilley wrote:

I don't understand, what am I checking them for? I have a variable of class "xyz" that has bean style properties, I'm placing that bean in the pageContext using the servlet call. Though the fact that the variable "xyz" is in the PC seems to be registered (given that "xyz" doesn't get highlighted) Idea doesn't seem to know what type the variable is. What could cause this? How should I look to fix it?


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Do not worry, I caught the problem in IDEA code, thank you for the
feedback. And next IDEA build will have the problem fixed :)

Stephen Cilley wrote:

I don't understand, what am I checking them for? I have a variable of class "xyz" that has bean style properties, I'm placing that bean in the pageContext using the servlet call. Though the fact that the variable "xyz" is in the PC seems to be registered (given that "xyz" doesn't get highlighted) Idea doesn't seem to know what type the variable is. What could cause this? How should I look to fix it?


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.