Channel with jsp display

Hi,

Is there anybody know how to create a channel with the content which is displayed by a jsp page.

Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

JSP display

One way to do that is to use Portlets, but I assume that is not what you are looking for. The other way is called a JSP Model II channel. It is covered in Chapter 3 of the Channel Developer Guide.

In a nutshell, create a class which implements the org.jasig.portal.channels.jsp.IController interface. The key interfaces are setStaticData (similar to the standard IChannel method), processRuntimeData (which is similar to setRuntimeData, except it returns a map of names to values to pass to the JSP page as request attributes), getJspMap (which returns a map from from logical name to JSP file name for rendering) and getJspToRender (which returns the logical name of the JSP to render for this request).

document

Zhen the name of the documentation you need is
Luminis SDK Channel Developer Guide

The file name is lp40100chnldg.pdf ... I have a copy I can email or you can get from sungard's website. :)

I got document

Carol,

Thanks!

Zhen

Create Channel

Thanks for the replying, actually recently our school needs to develop a feature which shows the age of the user’s password in a channel against AD, that means once user login to luminis, a channel shows user’s password expired status to the user. Basically as I know we should do some implementations:
1. Java code to connect and search AD.
2. Create jsp which include the step 1’s code to get AD’s “maxPwdAge" attribute,
3. The jsp should also get the luminis loginid (shortname) which will be used to search AD
4. Display the value of the “maxPwdAge” to the channel
I am not sure which type of channel is the most suitable for our case.
I read "Channel Development Guile" and for "JSP Model II channel", it did not give the code detail, do you have the code sample?
Thanks!

Suggestions

Here are some suggestions on how to do this:

First, I believe JSPs should be used for display logic only, and that business logic (such as retrieving the maxPwdAge attribute and using it to calculate a status value) should be kept in the Java. You can the results of your calculations to the JSP using the return Map from processRuntimeData. For display logic I like to use the JSP 2.0 expression language and JSTL (the standard tag library), both of which are available in Luminis 4.

To get the maxPwdAge attribute, you will need to get the IPerson object from the ChannelStaticData object passed to setStaticData. From there, you have at least two choices. First, you can get the login id or some similar piece of information and use JNDI to read AD. You can find lots of information on access AD through JNDI on the web. The other option is to use to define a person attribute containing the information (in personDirectory.xml) and retrieve it in the code from the IPerson object. There is information on how to define new person attributes on this site, in the Channel Developer Guide (Chapter 4) and on the uPortal site.

How can add this jsp to a channel

I read document, and create a channel and in the "Channel Class" field I add "org.jasig.portal.channels.CPersonAttributes", so the channel shows all the user information.
But if I create a jsp file, and using IPerson object to get user information, how can I add this jsp to the channel when I create a channel?
Thanks

Including the JSP file

You need to include the JSP in the CAR file. I usually put it in the same directory as the class file, which means you can just reference the file name in the Map returned by getJspMap

Question

What means "reference the file name in the Map returned by getJspMap?"
Thanks!

Calling JSP

In order to use the JSP you need to have a class which implements the IController interface. One of the methods in that interface is getJspMap, which returns a Map object for which the keys are the logical names you might return from getJsp, and the values are the JSP file names in your CAR file. For simpler channels (like the one you described above), you can have only one logical name and one JSP. For that, the getJspMap method can be as simple as:

return Collections.singletonMap("JSP", "display.jsp");

Where "JSP" is the logical name value always returned by getJsp and "display.jsp" is the name of the JSP file, which is in the same "directory" in your CAR file as your IController class.

Channel development

Thanks for your replying, I read doc for the knowledge of "jsp model II", I understand the structure, but I can not find code samples for the three main files: controller, bean and jsp in the document and also in internet, do you have any sample code? Thanks!

Jsp display question

If in getJspMap, return Collections.singletonMap("JSP", "display.jsp"), that means it should not modify the getJspToRender() to return the String key value?

Thanks!

Question of the getJspMap method

Thanks for the help.

I follow the instructions in the document, the jsp model II tye of channel has been created and car file is deployed to the server. I just made a very simple channel which just render a simple jsp with text display.
I did not override the getJspToRender method, I only override the getJspMap method as:

Map jsps=new HashMap();
jsps.put("JSP","display.jsp");
return jsps;

But I got the error message:
Inner exception:org.jasig.portal.PortalException: No JSP id returned by controller. at org.jasig.portal.channels.jsp.Channel.renderCharacters(Channel.java:121) at campuspipeline.uportal.ScheduledChannelRenderer$ScheduledWorker.run(ScheduledChannelRenderer.java:834) at com.pipeline.uportal.ChannelRendererTaskInterceptor$1.run(ChannelRendererTaskInterceptor.java:154) at java.security.AccessController.doPrivileged(Native Method) at com.pipeline.uportal.ChannelRendererTaskInterceptor.run(ChannelRendererTaskInterceptor.java:138) at campuspipeline.uportal.ScheduledChannelRenderer$ScheduledWorker.execute(ScheduledChannelRenderer.java:1108) at campuspipeline.util.concurrent.ThreadPoolExecutor$ThreadPoolTask.execute(ThreadPoolExecutor.java:422) at campuspipeline.util.concurrent.ThreadPoolExecutor$LimitedExecutorTask.run(ThreadPoolExecutor.java:493) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595)

Outter exception:org.jasig.portal.PortalException: General channel rendering failure. at campuspipeline.uportal.ScheduledChannelRenderer.completeRendering(ScheduledChannelRenderer.java:518) at org.jasig.portal.ChannelManager.outputChannel(ChannelManager.java:491) at org.jasig.portal.CharacterCachingChannelIncorporationFilter.endElement(CharacterCachingChannelIncorporationFilter.java:348) at org.apache.xml.serializer.ToHTMLSAXHandler.endElement(ToHTMLSAXHandler.java:243) at org.apache.xml.dtm.ref.DTMTreeWalker.endNode(DTMTreeWalker.java:373) at org.apache.xml.dtm.ref.DTMTreeWalker.traverse(DTMTreeWalker.java:132) at org.apache.xml.dtm.ref.sax2dtm.SAX2DTM.dispatchToEvents(SAX2DTM.java:748) at org.apache.xalan.serialize.SerializerUtils.outputResultTreeFragment(SerializerUtils.java:139) at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:190) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411) at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374) at

I have my Channel class file and jsp file in the same directory.

Hope can get some advices.

Thanks!

Look at getJsp

If I had to guess, you would get that error any time the getJsp method returned null. Given what you describe, it should return the string "JSP" so that the channel will call the display.jsp.

I got it

I got my jsp display, thanks!

zhenchen

Hello zhenchen,
I didn't start yet creatiing JSP channel...
Are you willing to share me ur experience in your first JSP channel...
Regards,
hmalla at hotmail

More question

Now the jsp model II channel is created, but if enter the input and submit, the whole page is refreshed, any body know how can the submit will not inference the whole page, just update the channel?

Thanks!

Syndicate content