PortletFaces provides the following UIComponent tags as part of its component suite.
Table 6.4. UIComponent Tags
| Tag | Description |
|---|---|
pf:inputFile
|
Renders an HTML <input type="file" /> tag which provides file
upload capability.
|
pf:inputRichText
|
Renders a text area that provides the ability to enter rich text such as bold, italic, and underline. |
pf:permissionsLink
|
Renders an HTML anchor tag (hyperlink) that the user can click on in order to see the Liferay Permissions screen for the associated resource. |
The pf:inputFile tag renders an HTML <input type="file"
/> tag which enables file upload capability.
Usage of this tag requires a faces-context-factory element to be placed in the
WEB-INF/faces-config.xml file. See the File Upload section for more details.
Table 6.5. Attributes
| Attribute | Type | Description | Required |
|---|---|---|---|
| id | String | The identifier of the component | false |
| rendered | Boolean | Boolean flag indicating whether or not this component is to be rendered during the RENDER_RESPONSE phase of the JSF lifecycle. The default value is “true”. | false |
| value | java.io.File | The value of the component, which will be a file on the server. | true |
Example 6.47. Example usage of pf:inputFile tag
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pf="http://portletfaces.org/facelets">
<h:form enctype="multipart/form-data">
<pf:inputFile value="#{managedBean.file}" />
<h:commandButton action="#{fileUploadManagedBean.submit}" value="Upload File" />
</h:form>
</f:view>
public class FileUploadManagedBean {
private File file;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String submit( {
System.out.println("Uploaded file: " + file);
return "filesUploaded";
}
}
The pf:inputRichText tag renders a text area that provides the ability to enter
rich text such as bold, italic, and underline. The renderer relies on the CKEditorTM to provide the rich
text editing area.
Since Liferay bundles the CKEditorTM JavaScript and related images with the portal, the portlet developer does not need to include it with the portlet.
Table 6.6. Attributes
| Attribute | Type | Description | Required |
|---|---|---|---|
| id | String | The identifier of the component | false |
| rendered | Boolean | Boolean flag indicating whether or not this component is to be rendered during the RENDER_RESPONSE phase of the JSF lifecycle. The default value is “true”. | false |
| value | String | The value of the component, the HTML fragment generated by the end-user. | true |
Example 6.48. Example usage of pf:inputRichText tag
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pf="http://portletfaces.org/facelets">
<h:form>
<pf:inputRichText id="comments" value="#{modelManagedBean.comments}" />
</h:form>
</f:view>
The pf:permissionsLink tag renders an HTML anchor tag (hyperlink) that the user can
click on in order to see the Liferay Permissions screen for the associated resource.
Table 6.7. Attributes
| Attribute | Type | Description | Required |
|---|---|---|---|
| id | String | The identifier of the component | false |
| modelResource | String | The fully qualified Java class of the model resource. For example:
MyModelResource.class.getName()
|
true |
| modelResourceDescription | String | The description of the model resource. | true |
| redirect | Boolean | The redirect URL. | false |
| rendered | Boolean | Boolean flag indicating whether or not this component is to be rendered during the RENDER_RESPONSE phase of the JSF lifecycle. The default value is “true”. | false |
| resourcePrimKey | String | The primary key value of the model resource. | true |
Example 6.49. Example usage of pf:permissionsLink tag
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:pf="http://portletfaces.org/facelets">
<h:form>
<pf:permissionsLink
modelResource="org.portletfaces.myproject.model.Book"
modelResourceDescription="Book"
resourcePrimKey="#{modelManagedBean.book.bookId} />
</h:form>
</f:view>