Announcement

Collapse
No announcement yet.

Portlet: JSF + Spring

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Portlet: JSF + Spring

    Hallo Leute,
    ich hoffe das mir hier vielleicht jemand helfen kann... sitze schon seit Tagen und bin am suchen...
    Ich arbeite zur Zeit an einem Portlet, das mit Spring und MyFaces realisiert werden soll... soweit hab ich alles auch konfiguriert aber wenn ich aus einer jsp
    datei eine (Spring-)Methode ausführen möchte... passiert einfach nicht...
    kennt das vielleicht einer von euch?

    hier ein ausschnitt nach dem deployment in Jboss:

    Code:
    2007-03-30 15:11:30,000 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Published PortletApplicationContext of portlet 'MilestonePortletBeta3' as PortletContext attribute with name [org.springframework.web.portlet.FrameworkPortlet.CONTEXT.MilestonePortletBeta3]
    2007-03-30 15:11:30,015 INFO [org.springframework.web.portlet.DispatcherPortlet] - Unable to locate PortletMultipartResolver with name 'portletMultipartResolver': no multipart request handling provided
    2007-03-30 15:11:30,015 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'portletModeHandlerMapping'
    2007-03-30 15:11:30,015 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter' with merged definition [Root bean: class [org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
    2007-03-30 15:11:30,015 INFO [org.springframework.web.portlet.DispatcherPortlet] - No HandlerAdapters found in portlet 'MilestonePortletBeta3': using default
    2007-03-30 15:11:30,031 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Creating instance of bean 'org.springframework.web.servlet.view.InternalResourceViewResolver' with merged definition [Root bean: class [org.springframework.web.servlet.view.InternalResourceViewResolver]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
    2007-03-30 15:11:30,046 INFO [org.springframework.web.portlet.DispatcherPortlet] - No ViewResolvers found in portlet 'MilestonePortletBeta3': using default
    2007-03-30 15:11:30,046 INFO [org.springframework.web.portlet.DispatcherPortlet] - FrameworkPortlet 'MilestonePortletBeta3': initialization completed in 4125 ms
    2007-03-30 15:11:30,046 INFO [org.springframework.web.portlet.DispatcherPortlet] - Portlet 'MilestonePortletBeta3' configured successfully
    und das krieg ich wenn ich eine Anfrage gesendet habe:

    Code:
    2007-03-30 15:12:06,281 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - DispatcherPortlet with name 'MilestonePortletBeta3' received render request
    2007-03-30 15:12:06,296 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Bound render request context to thread: org.jboss.portlet.JBossRenderRequest@37d0d
    2007-03-30 15:12:06,296 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Testing handler map [org.springframework.web.portlet.handler.PortletModeHandlerMapping@10713c7] in DispatcherPortlet with name 'MilestonePortletBeta3'
    2007-03-30 15:12:06,296 DEBUG [org.springframework.web.portlet.handler.PortletModeHandlerMapping] - Key [view] -> handler [org.springframework.web.portlet.mvc.PortletWrappingController@1d56250]
    2007-03-30 15:12:06,296 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Testing handler adapter [org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter@1a37ec1]
    2007-03-30 15:12:08,250 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MileStoneBeta3]] - No state saving method defined, assuming default server state saving
    2007-03-30 15:12:08,312 INFO [org.apache.myfaces.config.MyfacesConfig] - No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
    2007-03-30 15:12:08,312 INFO [org.apache.myfaces.config.MyfacesConfig] - No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
    2007-03-30 15:12:08,312 INFO [org.apache.myfaces.config.MyfacesConfig] - No context init parameter 'org.apache.myfaces.DETECT_JAVASCRIPT' found, using default value false
    2007-03-30 15:12:08,312 INFO [org.apache.myfaces.config.MyfacesConfig] - No context init parameter 'org.apache.myfaces.AUTO_SCROLL' found, using default value false
    2007-03-30 15:12:08,328 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Null ModelAndView returned to DispatcherPortlet with name 'MilestonePortletBeta3': assuming HandlerAdapter completed request handling
    2007-03-30 15:12:08,328 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Cleared thread-bound render request context: org.jboss.portlet.JBossRenderRequest@37d0d
    2007-03-30 15:12:08,328 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Successfully completed request
    2007-03-30 15:12:08,343 DEBUG [org.springframework.web.portlet.context.XmlPortletApplicationContext] - Publishing event in context [PortletApplicationContext for namespace 'MilestonePortletBeta3-portlet']: PortletRequestHandledEvent: portlet=[MilestonePortletBeta3]; mode=[view]; type=[render]; session=[321CF814D80477A13F40D0F60F9BB0C9]; user=[null]; time=[2047ms]; status=[OK]
    in web.xml hab ich das eingefügt:
    Code:
    <context-param>
    		<param-name>javax.faces.CONFIG_FILES</param-name>
    		<param-value>/WEB-INF/faces-config.xml</param-value>
    	</context-param>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/context/applicationContext.xml
    		</param-value>
    	</context-param>
    <listener>
    		<listener-class>
    			org.springframework.web.context.ContextLoaderListener
    		</listener-class>
    	</listener>
    und mein faces-config:
    Code:
    <application>
    		<variable-resolver>
    			org.springframework.web.jsf.DelegatingVariableResolver
    		</variable-resolver>
    	</application>
    
    	<managed-bean>
    		<managed-bean-name>jsfAgent</managed-bean-name>
    		<managed-bean-class>
    			main.org.jboss.portlet.milestonebeta.jsfagent.JsfAgent
    		</managed-bean-class>
    		<managed-bean-scope>application</managed-bean-scope>
    		<managed-property>
    			<property-name>mileStoneService</property-name>
    			<property-class>
    				main.org.jboss.portlet.milestonebeta.service.MileStoneService
    			</property-class>
    			<value>#{mileStoneService}</value>
    		</managed-property>
    	</managed-bean>
    
    	<managed-bean>
    		<managed-bean-name>backingBean</managed-bean-name>
    		<managed-bean-class>
    			main.org.jboss.portlet.milestonebeta.jsfagent.BackingBean
    		</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    		<managed-property>
    			<property-name>jsfAgent</property-name>
    			<property-class>main.org.jboss.portlet.milestonebeta.jsfagent.JsfAgent</property-class>
    			<value>#{jsfAgent}</value>
    		</managed-property>
    	</managed-bean>
    und milestone.xml:
    Code:
    <bean id="wrappingController"
              class="org.springframework.web.portlet.mvc.PortletWrappingController">
            <property name="portletClass" value="org.apache.myfaces.portlet.MyFacesGenericPortlet"/>
        </bean>
    <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
            <!-- 
            <property name="interceptors">
                <list>
                    <ref bean="myInterceptor"/>
                </list>
            </property> -->
            <property name="portletModeMap">
                <map>
                    <entry key="view">
                        <ref bean="wrappingController"/>
                    </entry>
                </map>
            </property>
        </bean>
        
    	<!-- Service: Accessing ... -->
    	
    	<bean id="mileStoneService" class="main.org.jboss.portlet.milestonebeta.service.MileStoneService">
    		<property name="portletPropertyManager"	ref="portletPropertyDao"/>
    		<property name="entryManager" 			ref="entryDao"/>
    		<property name="dataTypeManager" 		ref="dataTypeDao"/>
    		<!-- <property name="userService" ref="userService"/>  -->
    	</bean>
    Also ich bin mir nicht sicher ob da nicht ein Handler fehlt
    etwas stutzih macht mich das hier aus dem log:

    2007-03-30 15:12:08,328 DEBUG [org.springframework.web.portlet.DispatcherPortlet] - Null ModelAndView returned to DispatcherPortlet with name 'MilestonePortletBeta3': assuming HandlerAdapter completed request handling

    Ach ja so ruf ich das ganz auf:
    Code:
    <f:view>
    	<h:outputText value="TEST"/>
    	<h:outputText value="#{jsfAgent.mileStoneService.text}"/>
    </f:view>
    
    public class BackingBean {
    	
    	private JsfAgent jsfAgent;
    
    	public JsfAgent getJsfAgent() {
    		return jsfAgent;
    	}
    
    	public void setJsfAgent(JsfAgent jsfAgent) {
    		this.jsfAgent = jsfAgent;
    	}
    	
    
    }
    
    public class JsfAgent{
    	static Logger logger = Logger.getLogger(JsfAgent.class);
    	static{
    		logger.setLevel(Level.ALL);
    	}
    	
    	private MileStoneService mileStoneService;
    	
    	
    	public MileStoneService getMileStoneService() {
    		return mileStoneService;
    	}
    
    	public void setMileStoneService(MileStoneService mileStoneService) {
    		this.mileStoneService = mileStoneService;
    	}
    	
    	public List<Entry> getEntries(){
    		return getMileStoneService().getEntryManager().getEntrySet();
    	}
    	
    }
    
    und aus MileStoneService.java:
    
    private String text = "Hello";
    
    	public String getText() {
    		logger.debug("<<<<<<<<<<TEXT>>>>>>>>>>>>");
    		return text;
    	}
    
    
    	public void setText(String text) {
    		this.text = text;
    	}
    Vielen Danke im voraus, jeder Tipp würde mich weiterbringen...
    mfg
    omid

  • #2
    Hi Omid,

    was mich 'n bisschen stutzig macht ist das die xml-Datei Konfigurationsdatei in deiner web.xml /WEB-INF/context/applicationContext.xml heisst, in deiner Beschreibung nennst du sie milestone.xml...
    Kann es sein das da was nicht stimmt....?

    Comment

    Working...
    X