0

設定の値をオーバーライドしようとしていますが、何もオーバーライドされません。これを修正する方法を知っている人はいますか?

portlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
    <portlet>
        <portlet-name>cool_portlet</portlet-name>
        <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>view</portlet-mode>
        </supports>
        <supported-locale>en</supported-locale>
        <resource-bundle>com.app.portlet.cool_portlet</resource-bundle>
        <portlet-info>
            <title>Cool Portlet</title>
        </portlet-info>     
        <portlet-preferences>
            <preference>
                <name>KEY</name>
                <value>TEST</value>
                <read-only>false</read-only>
            </preference>
        </portlet-preferences>
    </portlet>
</portlet-app>

portlet-instances.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD Portlet Instances 2.6//EN" "http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
<deployments>
   <deployment>
      <instance>
         <instance-id>coolPortlet_IMPORT_newInstance</instance-id>
         <portlet-ref>cool_portlet</portlet-ref>
          <preferences>
              <name>KEY</name>
              <value>IMPORT</value>
          </preferences>
      </instance>
   </deployment>
    <deployment>
        <instance>
            <instance-id>coolPortlet_EXPORT_newInstance</instance-id>
            <portlet-ref>cool_portlet</portlet-ref>
            <preferences>
                <name>KEY</name>
                <value>EXPORT</value>
            </preferences>
        </instance>
    </deployment>
</deployments>

cool_portlet-object.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE deployments PUBLIC "-//JBoss Portal//DTD Portlet Instances 2.6//EN" "http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd">
<deployments>
    <deployment>
        <parent-ref>comportal.import</parent-ref>
        <if-exists>overwrite</if-exists>
        <window>
            <window-name>impWindow</window-name>
            <content>
                <content-type>portlet</content-type>
                <content-uri>coolPortlet_IMPORT_newInstance</content-uri>
            </content>
            <region>center</region>
            <height>1</height>
            <supported-window-states>
                <window-state>normal</window-state>
                <window-state>maximized</window-state>
                <window-state>minimized</window-state>
            </supported-window-states>
            <initial-window-state>normal</initial-window-state>
        </window>
    </deployment>
    <deployment>
        <parent-ref>comportal.export</parent-ref>
        <if-exists>overwrite</if-exists>
        <window>
            <window-name>expWindow</window-name>
            <content>
                <content-type>portlet</content-type>
                <content-uri>coolPortlet_EXPORT_newInstance</content-uri>
            </content>
            <region>center</region>
            <height>1</height>
            <supported-window-states>
                <window-state>normal</window-state>
                <window-state>maximized</window-state>
                <window-state>minimized</window-state>
            </supported-window-states>
            <initial-window-state>normal</initial-window-state>
        </window>
    </deployment>
</deployments>

MainController.java

@RequestMapping(value = "VIEW")
@Controller(value = "mainController")
public class MainController {
    @RenderMapping
    public String init(@RequestParam(value = "key", required = false) String key, Model model, PortletRequest request) throws Exception {
        PortletPreferences preferences = request.getPreferences();
        String preferencesKey = preferences.getValue("KEY", "Not Found!!!");
        System.out.println("KEY is : " + preferencesKey);
        model.addAttribute("preferencesKey", preferencesKey);
        return "index";
    }
}

出力:

13:49:54,860 INFO  [STDOUT] KEY is : TEST
13:50:21,088 INFO  [STDOUT] KEY is : TEST
4

1 に答える 1

1

setValue を呼び出してから、PortletPreferences オブジェクトを保存する必要があります。設定はアクション フェーズでのみ保存できることに注意してください。訪問

于 2012-09-18T06:20:34.240 に答える