aspose file tools*
The moose likes Portals and Portlets and the fly likes New JSF/Portlet Developer Help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "New JSF/Portlet Developer Help needed" Watch "New JSF/Portlet Developer Help needed" New topic
Author

New JSF/Portlet Developer Help needed

Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Hello All,

It has been a while since I posted to the ranch, but now that I am in development mode and I have some questions. Please forgive me for asking what may be trivial questions but I am complete newbie to all of these technologies. First of all my environment is Uportal 2.5.3, Java 5 and Tomcat 5.5 and JSR 168. I am also using the Apache foundations implementation of JSF, Myfaces 1.5. Couple of questions, when I deploy my portlet to Tomcat the navigation works correctly, however when I put my portlet into uPortal the application just refreshes to the same page. Strange. Also I created a Databaseutil class to update a database. This class implements the ActionListener. My supervisor told me that the way I wrote that class was the old way of writing to a database. He said the new JSF way was to put the database calls in the javabeans. Any ideas on what he was referring to? javascript: x()
Confused
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Don't worry about simple questions. Being able to answer simple questions makes us feel smart.

Could I get some clarification, because I'm not familiar with UPortal.

I'm assuming you have a JSF application that you are deploying to tomcat for testing, right? After all, you can't really deploy a portlet to tomcat. So, as a JSF web module, it is working correctly.

BUT, when you wrap it up as a portlet, and deploy to uPortal, it doesn't work. Well, it sorta works, but only the first page. Then, you can't get anything to work, other than the landing page.

Is that a good description of the problem?

With JetSpeed and JBoss, I need to download a JSF bridge to get my JSF applications to run as portlets. Is there/are you using a similar bridge to get JSF projects to work on uPortal? Is it required for uPortal?

As far as database access goes, well, the DAO pattern is always a great way to create a reusable layer that insulates your view and controller layer from you database layer.

As far as database access with POJOs, that's a field that has come a long, long way over the past two or three years. Hibernate is one of the leading technologies for implementing a persistence strategy that leverages your domain model JavaBeans. There are many others - Hibernate is just the one I know best.

With Hibernate you can simply decorate a JavaBean like this:

@Entity
public class User {

private Long id;
private String password;

@Id
@GeneratedValue

public Long getId() {return id;}

public void setId(Long id) {this.id = id;}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}
}

Then, saving, updating or deleting your POJO would look as simple as this:



If that's the direction you think you might be going, then follow my signature links for some more information and free tutorials on how to work with Hibernate.

Kindest regards,

-Cameron McKenzie
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Thanks for the prompt response and information. I stumbled across your website via google last week and now your responding to my post, very cool. Great web site btw!!
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Well after careful scrutiny of my web.xml file I discovered that I had a listener context that was throwing the behavior of the portlet off. Upwards and onwards.

[ June 12, 2008: Message edited by: Omar Barrera ]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

LOL...

Sometimes the simplest problems are the most difficult to diagnose.

Keep asking questions!

-Cameron McKenzie
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Will do. Thanks for your time and prompt response.
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Hello All,

I have another question regarding the jsf portlet I am working on. I can not get my database utility class to work. I added the actionListener tag to command component, added a web listener value to the web.xml and created three related classes, a DatabaseUtil class, an ApplicationContextListener, and ActionListener Class. If you have seen the code below it is becuase I modeled my code after this example. I have been able to trace my problem to the statement that calls the insert a record statement bolded below. The error I receive is java.lang.classcastexception. I don't even make it into the method.



[ June 17, 2008: Message edited by: Omar Barrera ]
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
I have been able to narrow down my problem even further. The problem lies with the following statement:



The error I am getting from tomcat is java.lang.ClassCastExeption: org.apache.pluto.core.impl.PortletContextImpl
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Yeah, it looks like you're getting back a PortletContext, not a ServletContext.

I think that PortletContext has a method called getServletContext(), but it does kinda make the JSF app very Portlet specific.

By the way, it's best to post new problems in a new thread, and reference the old thread with a link. Otherwise, people will skim over the old thread thinking the problem was solved.

Happy Portal!

-Cameron McKenzie
Omar Barrera
Greenhorn

Joined: Aug 17, 2005
Posts: 15
Thanks for the tip. And I will be sure to follow your posting recommendation.
 
 
subject: New JSF/Portlet Developer Help needed
 
Similar Threads
Portlet getting log off
JSF Portlet Question
Portlet communication
Redirecting or Forwarding to another Portlet with Params
uPortal 3.2.4 Build Failed