I've created a Liferay control panel portlet that works nicely.
Now I want to add a configuration page. I've done as follows:
Add config-template init-parameter to portlet.xml
Add configuration-action-class to the liferay-portlet.xml
But, the configuration menu does not appear:
Here are the two descriptors.
portlet.xml
<portlet>
<portlet-name>manage-apples-portlet</portlet-name>
<display-name>Apple Management Admin</display-name>
<portlet-class>de.apples.portlet.ManageApplesPortlet</portlet-class>
<init-param>
<name>config-template</name>
<value>/html/manage-apples-portlet/config.jsp</value>
</init-param>
<init-param>
<name>view-jsp</name>
<value>/html/manage-apples-portlet/view.jsp</value>
</init-param>
<init-param>
<name>jsp-path</name>
<value>/html/manage-apples-portlet/</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>content.Language</resource-bundle>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
liferay-portlet.xml
<portlet>
<portlet-name>manage-apples-portlet</portlet-name>
<icon>/icon.png</icon>
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
<control-panel-entry-category>content</control-panel-entry-category>
<control-panel-entry-weight>10.0</control-panel-entry-weight>
<instanceable>false</instanceable>
<css-class-wrapper>manage-apples-portlet</css-class-wrapper>
</portlet>
Am I missing something?
At first view, I don't see portlet modes in the support element, I think you should add
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
inside supports element of portlet.xml.
Related
I have just created new web application based on activeweb framework and by default it shows me "?" for all foreign language characters. Something like this:
? ????????? ??????
???? ????????? ??
?????? ??????????
? ??? ???? ??????????
??????????? ????????
English characters are displayed ok.
Here is my web.xml config:
<display-name>activeweb</display-name>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<filter>
<filter-name>dispatcher</filter-name>
<filter-class>org.javalite.activeweb.RequestDispatcher</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>css,img,fonts,images,js,html,GwtExample,ico</param-value>
</init-param>
<init-param>
<param-name>root_controller</param-name>
<param-value>home</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>dispatcher</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I expect that this problem might be related to encoding in activeweb internals or I have to apply special setting. Do you know how to fix it?
This happens because ActiveWeb does nothing about encoding by default, and what you get comes from the servlet container.In order to force a specific encoding (UTF-8, I assume), you need to add a line of configuration to the web.xml file:
<filter>
<filter-name>dispatcher</filter-name>
<filter-class>org.javalite.activeweb.RequestDispatcher</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>css,images,js,ico</param-value>
</init-param>
<init-param>
<param-name>root_controller</param-name>
<param-value>home</param-value>
</init-param>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
This will force UTF-8 encoding on request as well as response.
I am using Vaadin 7.1.7 and I can't figure out how to set session-timeout
parameter (to, say, 1min).
As far as I can tell, Vaadin 7.x.x does not produce web.xml, it uses #VaadinServletConfiguration annotation but there doesn't seem to be a session-timeout parameter.
As far as I know there are 2 ways to set session-timeout in Vaadin 7.
In the web.xml:
<session-config>
<session-timeout>1</session-timeout> <!-- 1 minute -->
</session-config>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.xyz.web.MyServlet</servlet-class>
<init-param>
<description>My Main Page</description>
<param-name>UI</param-name>
<param-value>com.xyz.web.MyUI</param-value>
</init-param>
<init-param>
<description>Enable Session Timeout (heartbeat can't keep alive)</description>
<param-name>closeIdleSessions</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Or we can set it programmatically (current session only):
VaadinSession.getCurrent().getSession().setMaxInactiveInterval(60); // 1 minute
It seems the servlet 3.0 annotations do not help: link
More help here: link
I've written an application using Glassfish 3.1.2.2 and Primefaces 4.0. This is really at the start, so there's not much going on. I have added Form-based security. When I first did this, I had all of the xhtml pages in the same folder in my WAR file. I was able to logout by having the following methd in my UserBean
public String logout() {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.invalidate();
return "welcomeRedir";
}
Where my faces-config.xml had the following navigation rule
<navigation-rule>
<navigation-case>
<from-outcome>welcomeRedir</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
Where welcome.xhtml is the original Login page. And, when I had it defined this way, it worked. I could login using a JDBC realm and when I clicked the logout button, the page navigated back to the welcome page.
Next, I wanted to add security constraints. So, I moved the relevant pages (but not the welcome page) to subsdirectories, and added the appropriate security-constraint elements to the web.xml. And I can still log into those pages.
But, when I click the logout button, nothing happens. If I look at the network traffic being sent from the browser, it's getting a 403 error as a response.
I've looked and looked, but I can't find anything relevant. Has anyone gotten this to work when security-constraints are defined?
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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-app_3_0.xsd">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- More efficient, in an AJAX environment, to have server side state saving -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<!-- HTML comments become components unless they're stripped -->
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<!-- PrimeFaces Theme -->
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>welcome.xhtml</welcome-file>
</welcome-file-list>
<resource-ref>
<res-ref-name>jdbc/resmandb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<security-constraint>
<display-name>Protected Pages</display-name>
<web-resource-collection>
<web-resource-name>ApplicationPages</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>registeredUser</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>System Admin Pages</display-name>
<web-resource-collection>
<web-resource-name>SysAdminPages</web-resource-name>
<description/>
<url-pattern>/sysadmin/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>authentication-realm</realm-name>
<form-login-config>
<form-login-page>/welcome.xhtml</form-login-page>
<form-error-page>/welcome.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>A System Admin of ResMan</description>
<role-name>admin</role-name>
</security-role>
<security-role>
<description>A Registered User of ResMan</description>
<role-name>registeredUser</role-name>
</security-role>
</web-app>
faces-config.xml
<faces-config version="2.1"
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_2_1.xsd">
<application>
<resource-bundle>
<base-name>messages</base-name>
<var>msg</var>
</resource-bundle>
</application>
<navigation-rule>
<navigation-case>
<from-outcome>welcome</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<navigation-case>
<from-outcome>welcomeRedir</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<navigation-case>
<from-outcome>reservations</from-outcome>
<to-view-id>/protected/reservations.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
As it turns out, it's nothing to do with the faces configuration and more about how my glassfish-web.xml defined its security-role-mapping elements. The values in the elements didn't match the groups contained within my JDBC Realm (ie, the names of the groups in my database tables). Once I defined these correctly, the logout works.
In truth, until I did this, none of the AJAX requests from Primefaces were being accepted. It wasn't a logout issue, it was a general interaction issue.
I am currently learning jsf. I have written A simple jsf application where my target is to navigate from one page to another page. However, I am unable to navigate at all.
In my code there are two jsp files; one is createcustomer.jsp and the other is viewCustomerDetails. After the user enters data in createcustomer.jsp and clicks on the button it should move to next page (where it will display entered data in previous page in this page).
Below is my code. Can anyone find where I'm going wrong?<
createCustomer.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>
<h1 style="background-color:blue;color:white;">Create a new Customer</h1>
</td>
</tr>
</table>
<f:view>
<table>
<tr><td>Name:</td><td><h:inputText value="#{customer.name}"></h:inputText></td></tr>
<tr><td>Address:</td><td><h:inputText value="#{customer.address}"></h:inputText></td></tr>
<tr><td>Phone Number:</td><td><h:inputText value="#{customer.phNumber}"></h:inputText></td></tr>
<tr><td>Email Address:</td><td><h:inputText value="#{customer.email_id}"></h:inputText></td></tr>
</table>
<table>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td><h:commandButton value="Create Customer" action="viewCustomerDetails" /></td></tr>
</table>
</f:view>
</body>
</html>
face-config.xml
<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_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>customer</managed-bean-name>
<managed-bean-class>com.app.view.Customer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/createcustomer.jsp</from-view-id>
<navigation-case>
<!-- <from-action>#{customer.validate}</from-action> -->
<from-outcome>viewCustomerDetails</from-outcome>
<to-view-id>/viewCustomerDetails.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
web.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_3_0.xsd" version="3.0">
<display-name>Customer</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>
Apparently, based on your code snipplet you have no <h:form> tag defined. Components such as <h:commandButton> need to be defined inside of one to function properly. Encase the content of your <f:view> inside an <h:form> and try again.
I'm migrating from RF3.3.3, JSF1.2 and jboss 5 to JSF2/ RF4. We have a rich toolbar group with dropdown menus that is generated from a database table. I made the changes to web.xml, renamed the applicable components in the backing bean, but the toolbar will only show as text instead of dropdown menus and links.
web.xml:
<?xml version="1.0"?>
<web-app version="3.0" 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-app_3_0.xsd">
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinningClasses</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.resourceOptimization.enabled</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>blueSky</param-value>
</context-param>
menu.xhtml - included in a template.xhtml with h:head and h:body tags:
<h:form id="mnMenu">
<rich:toolbar id="tb" >
<rich:toolbarGroup>
<s:link id="menuHomeId" view="/home.xhtml" value="Home" propagation="none"/>
</rich:toolbarGroup>
<rich:toolbarGroup binding="#{menuQueries.myBarGrp}" />
</rich:toolbar>
<!-- account for jsf bug? bug DOESN'T WORK -->
<rich:toolbar rendered="false"/>
<rich:toolbarGroup rendered="false"/>
<rich:dropDownMenu rendered="false"/>
<rich:menuGroup rendered="false"/>
<rich:menuItem rendered="false"/>
</h:form>
from backing bean - this method creates the toolbar group, it originally looked like this:
public HtmlToolBarGroup getMyBarGrp()
{
this.myBarGrp = new org.richfaces.component.html.HtmlToolBarGroup();
for (CtsPermissionHierarchyAltV each : this.getMainMenuList()) {
this.myBarGrp.getChildren().add(getDropDownMenu(each));
}
return this.myBarGrp;
}
I changed it to this, both generate the same output:
public UIToolbarGroup getMyBarGrp()
{
FacesContext ctx = FacesContext.getCurrentInstance();
this.myBarGrp = (UIToolbarGroup) ctx.getApplication().createComponent(ctx,
UIToolbarGroup.COMPONENT_TYPE, "org.richfaces.ToolbarGroupRenderer");
this.myBarGrp.setId("dynMenuGrp");
for (CtsPermissionHierarchyAltV each : this.getMainMenuList())
{
this.myBarGrp.getChildren().add(getDropDownMenu(each));
}
}
the getDropDownMenu and submenu methods are coded similarly.
I'm not getting any errors. FF firebug output for text that should be a dropdown menu looks like this:
<div id="mnMenu:Communications" class="rf-ddm-lbl rf-ddm-unsel ">
... more stuff
Pre-migration it looked like this:
<div id="mnMenu:Communications" class="rich-ddmenu-label rich-ddmenu-label-unselect">
... more stuff
Navigating through the firebug output I can see all the submenus - but they're all text references.
I see all my css files - they're showing up in body instead of head, but they're all there.
Did I miss something? What else can I check?
jboss 7.1.1 Seam 2.3.0 JSF2.1 RichFaces 4.2.2
Likely to be a resource problem. When you select one of the items in Firebug, do you see any matching CSS declarations (rf-ddm-lbl or rf-ddm-unsel)? Did you check for any 404 errors in using firebugs net tab?
BTW: CSS files should be referenced in the header.
Found the answer here. I needed to add
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/org.richfaces.resources/*</url-pattern>
</servlet-mapping>
to web.xml. Not sure why it worked though, this solution is for containers using servlet2.5, and (as far as I know) I'm using servlet3.0.
claudegex your answer put me on the path to fix it - there actually were 404 errors. I'll mark this one correct after the bounty is over, you should get 1/2 of it.