9 Replies Latest reply on Mar 12, 2007 12:18 PM by vaalati

    Issue with JSF <f:view> tag

    vaalati

      Hi,
      I am trying to use JSF to develop a portlet and when I load the Portlet in a page I get an error which says

      javax.portlet.PortletException: Org.apache.jasper.JasperException:Exception in JSP

      And this exception points to the line in the JSP where the <f:view> tag is defined. I have pasted the code in my JSP below. Could some one please tell me what is wrong with it and why I am getting the error.

      I am extending the GenericPortlet to write my own Portlet class. I hope this should not be an issue, correct?

      Thanks much,
      Vijay



      <%@ page language="java" session="true" %>
      <%@ page import = "java.util.HashMap" %>
      <%@ page import = "javax.swing.*" %>
      <%@ page import = "javax.portlet.PortletSession" %>

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portlet" %>

      <portlet:defineObjects/>

      <portlet:actionURL var="loginAction">
      <portlet:param name="command" value="doLogin" />
      </portlet:actionURL>

      <%
      HashMap dbMap = new HashMap();
      dbMap.put((Object)(new String("DB 1")),(Object)(new String("1")));
      dbMap.put((Object)(new String("DB 2")),(Object)(new String("2")));
      %>



      ADM Login Page


      <f:view>
      </f:view>

        • 1. Re: Issue with JSF <f:view> tag
          ssilvert

          You need to extend MyFacesGenericPortlet instead.

          See http://wiki.apache.org/myfaces/Using_Portlets

          Stan
          http://jsf.jboss.org

          • 2. Re: Issue with JSF <f:view> tag
            vaalati

            Hi Stan,
            Thanks for help. Actually I had figured that out the hard way just a while ago before I received your reply.

            But now I ran into another issue. I wrote a JSF code in which I have a text-field (<h:inputText>) and I want to access the value entered in it in my portlet class which I wrote extending the MyFacesGenericPortlet. So how do I access it?s value? Usually in Servlets we can do this by using the request.getParameter(). Below is my code in which I have the text-field (<h:inputText>). Now how do I access it?s value in my portlet class?


            -----------------------------------------------------------------
            <%@ page language="java" session="true" %>
            <%@ page import = "javax.portlet.PortletSession" %>

            <%@ page language="java" pageEncoding="ISO-8859-1"%>
            <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
            <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
            <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portlet" %>
            <f:loadBundle basename="altair.adm.login.messages" var="msg"/>
            <portlet:defineObjects/>
            <portlet:actionURL var="loginAction">
            <portlet:param name="command" value="doLogin" />
            </portlet:actionURL>



            ADM Login


            <f:view>

            <h:form>
            <h:panelGrid columns="2">
            <h:outputText value="#{msg.user_id_tag}" />
            <h:inputText value="" required="true" id="ADM_USER_ID" />
            <h:commandButton action="#{loginAction}"
            value="#{msg.login_button_tag}" id="ADM_LOGIN_BUTTON"/>
            </h:panelGrid>

            </h:form>

            </f:view>



            -----------------------------------------------------------------


            Thanks,
            Vijay

            • 3. Re: Issue with JSF <f:view> tag
              ssilvert

              portletRequest.getParameter()

              • 4. Re: Issue with JSF <f:view> tag
                vaalati

                Hi Stan,

                Are you saying that if I have the below form element:

                <h:inputText value="" required="true" id="ADM_USER_ID" />


                Then I can access the above field value in my portlet's doView() method (which extends MyFacesGenericPortlet) using renderRequest.getParameter(paramName) ?

                If that is so, then getParameter(paramName) accepts the name of the field and not the ID of the field, right? Then in the above code I do not have a name for the field but I have an ID. So how do I access it's value now? Is there some thing more that I need to do?

                Please help.

                Thanks much,
                Vijay

                • 5. Re: Issue with JSF <f:view> tag
                  ssilvert

                  If you have also given the surrounding form an id then the param name will be something like "formid:ADM_USER_ID". If not, JSF will make up its own id.

                  Stan

                  • 6. Re: Issue with JSF <f:view> tag
                    ssilvert

                    BTW, doing this inside portlet code is not the recommended way to access the param. You should do it inside the JSF framework if possible.

                    Stan
                    http://jsf.jboss.com

                    • 7. Re: Issue with JSF <f:view> tag
                      vaalati

                      Hi Stan,
                      I tried the following ways but could not succeed:

                      1)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("vijay_form:ADM_USER_ID");
                      2) ((PortletRequest)request).getParameter("vijay_form:ADM_USER_ID");
                      3) request.getParameter("vijay_form:ADM_USER_ID");
                      4)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("ADM_USER_ID");


                      I tried quickly going through the MyFaces link you sent previously. But I could not find (probably I missed a lot..to be read) any help where I could know how to retrieve the value.

                      But in your previous reply you were mentioning that my approach was not correct. Could you please explain and/or give more details into what should be my approach to retrieve the values.

                      I really appreciate your time on my issue. I am a beginner and I do not have much help from anyone who might know/worked with JSF before.

                      Thanks very much,
                      Vijay

                      • 8. Re: Issue with JSF <f:view> tag
                        ssilvert

                        I'm sorry. I don't have time to give you an individual tutorial. There are plenty of good books at the bookstore and good tutorials on line.

                        Stan

                        • 9. Re: Issue with JSF <f:view> tag
                          vaalati

                          Hi Stan,

                          Instead of JSF, I moved my code to JSP and wrote my portlet extending the GenericPortlet. Now I try to access the request.getParameter() and it still gives me a null return. So what I am thinking here is that is there any setting/configuration that I need to do in JBoss portal/application server and due to which I am having this problem of not being able to access the form parameters using request.getParameter()?

                          Please help.

                          Thanks,
                          Vijay