4 Replies Latest reply on Oct 23, 2007 3:41 PM by kicho007

    using tomahawk file upload with modal panel

    kicho007

      Hi all!

      I'm pretty much new with rich faces so i'm not sure if i'm posting a concrete issue here. I'm trying to use tomahawk's file upload component in combination with modal panel. I.e. i have a modal panel with form on it, and that contains t:inputFileUpload.

      Something like this:

      <rich:modalPanel id="profilesModalPanel" resizeable="true" moveable="true">
      <f:facet name="header">
      <h:outputText value="Text"/>
      </f:facet>
      <f:facet name="controls">
      <h:outputLink value="#" styleClass="outputLink" onmouseover="cursor: pointer" onclick="javascript:Richfaces.hideModalPanel('companyModalPanel');">
      <h:outputText value="Close"/>
      </h:outputLink>
      </f:facet>
      <h:form id="profileModalDialogForm" styleClass="form" enctype="multipart/form-data">
      <rich:panel>
      <a4j:outputPanel ajaxRendered="true">
      <h:messages id="error"></h:messages>
      </a4j:outputPanel>
      <h:panelGrid id="profileModalDialogPanelGrid" styleClass="panelGrid" columns="2">
      <t:inputFileUpload id="modalMmsContentSelect" value="#{mmProfileListPage.upFile}" storage="file" rendered="#{mmProfileListPage.selectedProfile.profileType == 'PROFILE_MMS'}" required="true" />
      </h:panelGrid>
      </rich:panel>
      <rich:panel>
      <a4j:commandButton eventsQueue="foo" id="modalSubmit" reRender="dataTable" action="#{mmProfileListPage.submitSelectedProfile}" type="submit" value="Submit"
      oncomplete="if (document.getElementById('profileModalDialogForm:error')==null){ Richfaces.hideModalPanel('profilesModalPanel');}"/>
      <a4j:status startText="Start" stopText="stop"/>
      </rich:panel>
      </h:form>
      </rich:modalPanel>

      This is the problem: when i press the submit button, no content is being uploaded on the server (mmProfileListPage.upFile is null), modal panel closes and that's it! What am i doing wrong? Any suggestion is more than welcome. Thanks in advance!

        • 1. Re: using tomahawk file upload with modal panel
          kicho007

          I forgot to send you backing bean code sample:

          public class MMProfileListPage extends PageCodeBase{

          private UploadedFile upFile;

          ....

          public void submitSelectedProfile() {
          log.debug("MMProfileListPage::submitSelectedProfile::called");
          try {
          if (getSelectedProfile() != null) {
          if (getUpFile() != null) {
          try {
          getSelectedProfile().setMmsContent(getUpFile().getBytes());
          } catch (IOException e) {
          FacesContext.getCurrentInstance().addMessage(null,
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", ""));
          e.printStackTrace();
          }
          getSelectedProfile().setMmsContentName(getUpFile().getName());
          getSelectedProfile().setMmsContentType(getUpFile().getContentType());
          } else {
          log.debug("The file is null...");
          }

          }
          } catch (MMProfileServiceException e) {
          FacesContext.getCurrentInstance().addMessage(null,
          new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", ""));
          e.printStackTrace();
          }
          }

          }

          • 2. Re: using tomahawk file upload with modal panel
            richard.schramm

            What versions of JSF, Tomahawk, and Rich Faces are you using? Are you using Facelets as well? Can your web.xml and faces-config.xml?

            Rich

            • 3. Re: using tomahawk file upload with modal panel
              richard.schramm

              I meant post your web and faces-config xml files.

              • 4. Re: using tomahawk file upload with modal panel
                kicho007

                JSF: 1.2 RI (Sun)
                RichFaces: 3.1.2-GA
                Tomahawk: 1.1.6

                I don't use facelets.

                Here are my web.xml and faces-config.xml:

                <?xml version="1.0" encoding="utf-8"?>
                <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
                <display-name>BHTComTestWeb</display-name>
                <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
                </welcome-file-list>
                <context-param>
                <param-name>org.richfaces.SKIN</param-name>
                <param-value>blueSky</param-value>
                </context-param>

                <listener-class>com.sun.faces.config.ConfigureListener</listener-class>


                <listener-class>hr.combis.bhtcom.web.listener.WebContextListener</listener-class>


                <filter-name>MyFacesExtensionsFilter</filter-name>
                <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
                <init-param>
                <param-name>maxFileSize</param-name>
                <param-value>1m</param-value>
                </init-param>
                <init-param>
                <param-name>uploadThresholdSize</param-name>
                <param-value>600k</param-value>
                </init-param>

                <filter-mapping>
                <filter-name>MyFacesExtensionsFilter</filter-name>
                <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
                </filter-mapping>
                <filter-mapping>
                <filter-name>MyFacesExtensionsFilter</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                </filter-mapping>

                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>


                <servlet-name>SmsNotificationImpl</servlet-name>
                <servlet-class>hr.combis.bhtcom.sms.notification.service.SmsNotificationImpl</servlet-class>
                <load-on-startup>2</load-on-startup>


                <display-name>RichFaces Filter</display-name>
                <filter-name>richfaces</filter-name>
                <filter-class>org.ajax4jsf.Filter</filter-class>

                <filter-mapping>
                <filter-name>richfaces</filter-name>
                <servlet-name>Faces Servlet</servlet-name>
                REQUEST
                FORWARD
                INCLUDE
                </filter-mapping>

                <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.faces</url-pattern>
                </servlet-mapping>
                <servlet-mapping>
                <servlet-name>SmsNotificationImpl</servlet-name>
                <url-pattern>/services/SmsNotificationImpl</url-pattern>
                </servlet-mapping>

                <!-- Dodati nekakvi autorizacijski filter -->

                <ejb-local-ref id="EJBLocalRef_1174593993812">

                <ejb-ref-name>ejb/serviceExecutor</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <local-home>hr.combis.bhtcom.ejbs.facade.ServiceExecutorLocalHome</local-home>
                hr.combis.bhtcom.ejbs.facade.ServiceExecutorLocal
                <ejb-link>BHTComTestEJB.jar#ServiceExecutor</ejb-link>
                </ejb-local-ref>
                <resource-ref id="ResourceRef_UniMsgDataSource">

                <res-ref-name>jdbc/RFIDB</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
                </resource-ref>
                </web-app>


                <?xml version="1.0" encoding="utf-8"?>
                <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" version="1.2">

                <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
                <message-bundle>hr.combis.bhtcom.web.resources.ApplicationResources</message-bundle>

                <managed-bean>
                <managed-bean-name>mainMenuPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.main.MainMenuPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>mainPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.main.MainPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>featureHandlingPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.feature.FeatureHandlingPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                <managed-property>
                <property-name>configService</property-name>
                #{configService}
                </managed-property>
                <managed-property>
                <property-name>cbnService</property-name>
                #{cbnService}
                </managed-property>
                <managed-property>
                <property-name>mmService</property-name>
                #{mmService}
                </managed-property>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>cbnClientListPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.client.CBNClientListPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                <managed-property>
                <property-name>companyService</property-name>
                #{cbnCompanyService}
                </managed-property>
                <managed-property>
                <property-name>keywordService</property-name>
                #{keywordService}
                </managed-property>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>cbnKeywordListPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.keyword.CBNKeywordsListPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>mmClientListPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.client.MMClientListPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                <managed-property>
                <property-name>companyService</property-name>
                #{mmCompanyService}
                </managed-property>
                </managed-bean>
                <managed-bean>
                <managed-bean-name>mmProfileListPage</managed-bean-name>
                <managed-bean-class>hr.combis.bhtcom.web.pages.profiles.MMProfileListPage</managed-bean-class>
                <managed-bean-scope>request</managed-bean-scope>
                <managed-property>
                <property-name>profileService</property-name>
                #{mmProfileService}
                </managed-property>
                </managed-bean>

                <navigation-rule>
                <from-view-id>/pages/main/mainMenu.jsp</from-view-id>
                <navigation-case>
                <from-action>#{mainMenuPage.doNavigate}</from-action>
                <from-outcome>error</from-outcome>
                <to-view-id>/pages/main/mainPage.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                <from-action>#{mainMenuPage.doNavigate}</from-action>
                <from-outcome>featureHandlingPage</from-outcome>
                <to-view-id>/pages/feature/featureHandlingPage.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                <from-action>#{mainMenuPage.doNavigate}</from-action>
                <from-outcome>cbnCompanyListPage</from-outcome>
                <to-view-id>/pages/clients/cbnClientListPage.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                <from-action>#{mainMenuPage.doNavigate}</from-action>
                <from-outcome>mmCompanyListPage</from-outcome>
                <to-view-id>/pages/clients/mmClientListPage.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                <from-action>#{mainMenuPage.doNavigate}</from-action>
                <from-outcome>mmProfileListPage</from-outcome>
                <to-view-id>/pages/profiles/mmProfileListPage.jsp</to-view-id>
                </navigation-case>
                </navigation-rule>
                </faces-config>

                I'm not quite sure why do you need faces-config.xml...