i added a Java class to the src directory in my Portlet Factory project.
In the PF WAR file, i've confirmed that my class file appears in WEB-INF/work/classes/myPackage/myClass.class.
In Method builders, i can select my class in the import section.
However, when i insert <%@ page import="myPackage.myClass" %> into Page builder text and then try
to manipulate an instance of my class, i get "package does not exist" and "cannot resolve symbol"
JSP compilation errors.
PF JSPs aren't really different than any other JSP - they're compiled and run by the appserver, using the appserver's web application classloader, which only knows about classes under WEB-INF/classes and WEB-INF/lib not application specific classpaths. The WPF work/source and work/classes locations are WPF specific, used by the WPF dynamic classloader, and thus only used by WPF runtime, which knows about that classloader (and thus also by classes loaded by WPF runtime classes).
What is it that you need to access directly from the JSP? Typically Java is accessed via LJO and WPF builder from pages and not directly by hand-coding java references onto the page. If you can describe what you're trying to access and when/why, we may be able to suggest the best way to do so from a WPF page.
The JSP pages are loaded by a JSP class loader which delegates to the standard J2EE WAR class loader. The classes added to WEB-INF/work/source (or classes) are loaded by the WPF dynamic class loader (which provides the capability for classes to be dynamically reloaded). The classes in WEB-INF/work/source cannot be loaded by the J2EE WAR class loader. So, this is why you are getting the JSP compilation errors.
The correct way to handle this is to use the Linked Java Object builder to reference your class in the model. (The Linked Java Object builder will properly load your class through the WPF dynamic class loader.) You can then use the WebAppAccess class to invoke methods on your LJO. In a JSP, you could write webAppAccess.callMethod("LJOname.methodName", args).
I also have to ask, why you are writing code manually in a JSP page. In most, if not all, WPF projects that I've built, there is no need to write code in a JSP. The WPF builders should be used to accomplish the task. If you can provide a bit more context about what you're trying to do, maybe we can find a better solution to the problem.
Hi,I packaged the java classess which will be used in the jsp pages into a jar,and put this jar
into WEB-INF/lib .The java class will be found .Or, the other way, add your classes to the WEB-INF/classess on your own.
By the way ,our approach using WPF is not a WPF style ,we just use Page,Action List Builder,
like traditional MVC pattern.LJO is invoked only when the business action will be taken.
And So, We use Value Object in Page, and we import java classes.
I do not like this style,but I can not decide which approach we will take. I am not a decision maker.
But ,after long time study,I really recomment you to develop WPF like WPF.
Tags
Use the search field to
find all types of content in My developerWorks with that tag.
Use the slider bar to see more or fewer tags.
Popular tags shows the top tags for this particular type of content or application that you're viewing.
My tags shows your tags for this particular type of content or application that
you're viewing.