Seam SVN: r7885 - trunk/src/main/org/jboss/seam/security/management/action.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-09 06:55:14 -0400 (Wed, 09 Apr 2008)
New Revision: 7885
Modified:
trunk/src/main/org/jboss/seam/security/management/action/RoleAction.java
trunk/src/main/org/jboss/seam/security/management/action/RoleSearch.java
trunk/src/main/org/jboss/seam/security/management/action/UserAction.java
trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java
Log:
namespace
Modified: trunk/src/main/org/jboss/seam/security/management/action/RoleAction.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/action/RoleAction.java 2008-04-09 09:44:49 UTC (rev 7884)
+++ trunk/src/main/org/jboss/seam/security/management/action/RoleAction.java 2008-04-09 10:55:14 UTC (rev 7885)
@@ -12,7 +12,7 @@
import org.jboss.seam.core.Conversation;
import org.jboss.seam.security.management.IdentityManager;
-@Name("roleAction")
+@Name("org.jboss.seam.security.management.roleAction")
@Scope(CONVERSATION)
public class RoleAction
{
Modified: trunk/src/main/org/jboss/seam/security/management/action/RoleSearch.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/action/RoleSearch.java 2008-04-09 09:44:49 UTC (rev 7884)
+++ trunk/src/main/org/jboss/seam/security/management/action/RoleSearch.java 2008-04-09 10:55:14 UTC (rev 7885)
@@ -12,7 +12,7 @@
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.security.management.IdentityManager;
-@Name("org.jboss.seam.security.roleSearch")
+@Name("org.jboss.seam.security.management.roleSearch")
@Scope(SESSION)
public class RoleSearch implements Serializable
{
Modified: trunk/src/main/org/jboss/seam/security/management/action/UserAction.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/action/UserAction.java 2008-04-09 09:44:49 UTC (rev 7884)
+++ trunk/src/main/org/jboss/seam/security/management/action/UserAction.java 2008-04-09 10:55:14 UTC (rev 7885)
@@ -19,7 +19,7 @@
*
* @author Shane Bryzak
*/
-@Name("org.jboss.seam.security.userAction")
+@Name("org.jboss.seam.security.management.userAction")
@Scope(CONVERSATION)
public class UserAction implements Serializable
{
Modified: trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java 2008-04-09 09:44:49 UTC (rev 7884)
+++ trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java 2008-04-09 10:55:14 UTC (rev 7885)
@@ -14,7 +14,7 @@
import org.jboss.seam.security.management.IdentityManager;
-//@Name("userSearch")
+@Name("org.jboss.seam.security.management.userSearch")
@Scope(SESSION)
@Synchronized
public class UserSearch implements Serializable
16 years, 7 months
Seam SVN: r7884 - in trunk/examples/wiki: src/etc/i18n and 14 other directories.
by seam-commits@lists.jboss.org
Author: christian.bauer(a)jboss.com
Date: 2008-04-09 05:44:49 -0400 (Wed, 09 Apr 2008)
New Revision: 7884
Added:
trunk/examples/wiki/view/includes/confirmationAction.xhtml
Modified:
trunk/examples/wiki/src/etc/META-INF/wiki.taglib.xml
trunk/examples/wiki/src/etc/i18n/messages_en.properties
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryBrowser.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
trunk/examples/wiki/view/dirDisplay_d.xhtml
trunk/examples/wiki/view/dirEdit_d.xhtml
trunk/examples/wiki/view/docDisplay_d.xhtml
trunk/examples/wiki/view/docEdit_d.xhtml
trunk/examples/wiki/view/includes/userControl.xhtml
trunk/examples/wiki/view/plugins/forumList/forumForm.xhtml
trunk/examples/wiki/view/plugins/forumReplies/plugin.xhtml
trunk/examples/wiki/view/themes/default/js/lacewiki.js
trunk/examples/wiki/view/themes/default/template.xhtml
trunk/examples/wiki/view/themes/inrelationto/js/lacewiki.js
trunk/examples/wiki/view/themes/inrelationto/template.xhtml
trunk/examples/wiki/view/themes/sfwkorg/js/lacewiki.js
trunk/examples/wiki/view/themes/sfwkorg/template.xhtml
trunk/examples/wiki/view/uploadEdit_d.xhtml
trunk/examples/wiki/view/userHome_d.xhtml
Log:
Fixed delete confirmation popup javascript code injection hole
Modified: trunk/examples/wiki/src/etc/META-INF/wiki.taglib.xml
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/wiki.taglib.xml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/etc/META-INF/wiki.taglib.xml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -91,6 +91,12 @@
</function>
<function>
+ <function-name>escapeJSMessage</function-name>
+ <function-class>org.jboss.seam.wiki.util.WikiUtil</function-class>
+ <function-signature>java.lang.String escapeJSMessage(java.lang.String)</function-signature>
+ </function>
+
+ <function>
<function-name>encodeURL</function-name>
<function-class>org.jboss.seam.wiki.util.WikiUtil</function-class>
<function-signature>java.lang.String encodeURL(java.lang.String)</function-signature>
Modified: trunk/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- trunk/examples/wiki/src/etc/i18n/messages_en.properties 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/etc/i18n/messages_en.properties 2008-04-09 09:44:49 UTC (rev 7884)
@@ -163,9 +163,7 @@
lacewiki.label.WritableBy=Writable by
lacewiki.label.WriteProtected=Restrict edit access to admins
lacewiki.label.User=User
-lacewiki.label.DeleteConfirmation=Delete Confirmation
lacewiki.label.AreYouSureYouWantToDelete=Are you sure you want to delete
-lacewiki.label.DeleteAllChildren=?
lacewiki.label.Confirmation=Confirmation
lacewiki.label.AreYouSureYouWantToExecute=Are you sure you want to execute this operation?
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -135,7 +135,7 @@
public String remove(Long commentId) {
setNodeId(commentId);
- initEditor();
+ initEditor(false);
if (isManaged()) {
// Additional permission required besides NodeHome.remove()
@@ -274,7 +274,7 @@
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public String newComment() {
- initEditor();
+ initEditor(false);
showForm = true;
return "redirectToDocument";
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryBrowser.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryBrowser.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryBrowser.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -432,8 +432,10 @@
return false;
// Check permissions TODO: This duplicates the check
- if (!Identity.instance().hasPermission("Node", "edit", node))
+ if (!Identity.instance().hasPermission("Node", "edit", node)) {
+ log.debug("user doesn't have edit permissions for this node: " + node);
return false;
+ }
NodeRemover remover;
if (node.isInstance(WikiDocument.class)) {
@@ -441,9 +443,11 @@
} else if (node.isInstance(WikiUpload.class)) {
remover = (NodeRemover) Component.getInstance(UploadNodeRemover.class);
} else {
+ log.warn("no remover found for node type: " + node);
return false;
}
boolean removable = remover.isRemovable(node);
+ log.debug("remover said it's removable: " + removable);
childNodesRemovability.put(node.getId(), removable);
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -85,19 +85,25 @@
public boolean isEditor() { return editor; }
- public void initEditor() {
+ public void initEditor(boolean visibleWorkspace) {
getLog().debug("initializing editor workspace");
this.editor = true;
- // Set workspace description of the current conversation
- String desc = getEditorWorkspaceDescription(getNodeId() == null);
- WikiPreferences prefs = Preferences.getInstance(WikiPreferences.class);
- if (desc != null && desc.length() > prefs.getWorkspaceSwitcherDescriptionLength()) {
- desc = desc.substring(0, prefs.getWorkspaceSwitcherDescriptionLength().intValue()) + "...";
+ if (visibleWorkspace) {
+ // Set workspace description of the current conversation
+ String desc = getEditorWorkspaceDescription(getNodeId() == null);
+ WikiPreferences prefs = Preferences.getInstance(WikiPreferences.class);
+ if (desc != null && desc.length() > prefs.getWorkspaceSwitcherDescriptionLength()) {
+ desc = desc.substring(0, prefs.getWorkspaceSwitcherDescriptionLength().intValue()) + "...";
+ }
+ Conversation.instance().setDescription(desc);
}
- Conversation.instance().setDescription(desc);
}
+ public void initEditor() {
+ initEditor(true);
+ }
+
/* -------------------------- Basic Overrides ------------------------------ */
@Override
@@ -285,7 +291,7 @@
public String remove(Long nodeId) {
getLog().debug("requested node remove with id: " + nodeId);
setNodeId(nodeId);
- initEditor();
+ initEditor(false);
String outcome = remove();
if (outcome != null) {
Events.instance().raiseEvent("Node.refreshList");
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/faqBrowser/FaqQuestionHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -141,7 +141,7 @@
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void newQuestion() {
- initEditor();
+ initEditor(false);
showForm = true;
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ForumHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -201,14 +201,14 @@
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void newForum() {
- initEditor();
+ initEditor(false);
showForm = true;
}
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void edit(Long forumId) {
setId(forumId);
- initEditor();
+ initEditor(false);
showForm = true;
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/ReplyHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -57,7 +57,7 @@
getLog().debug("reply to document id: " + getParentNodeId());
newComment();
- initEditor();
+ initEditor(false);
getInstance().setSubject(REPLY_PREFIX + getParentNode().getName());
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -237,7 +237,7 @@
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void newTopic() {
- initEditor();
+ initEditor(false);
showForm = true;
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java 2008-04-09 09:44:49 UTC (rev 7884)
@@ -161,6 +161,10 @@
}
}
+ public static String escapeJSMessage(String message) {
+ return message.replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\\\"");
+ }
+
public static String escapeEmailURL(String string) {
return string.length() >= 7 && string.substring(0, 7).equals("mailto:")
? string.replaceAll("@", Preferences.getInstance(WikiPreferences.class).getAtSymbolReplacement())
Modified: trunk/examples/wiki/view/dirDisplay_d.xhtml
===================================================================
--- trunk/examples/wiki/view/dirDisplay_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/dirDisplay_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -217,16 +217,27 @@
<h:outputText value="#{messages['lacewiki.button.dirDisplay.ViewNewWindow']}"/>
</h:outputLink>
</li>
+
<s:fragment rendered="#{directoryBrowser.isRemovable(node)}">
- <a:jsFunction name="deleteDocumentId#{node.id}"
- status="globalStatus"
- action="#{documentHome.remove(node.id)}"/>
<li>
- <h:outputLink value="javascript:deleteConfirmation('\\'#{node.name}\\'','deleteDocumentId#{node.id}')">
- <h:outputText value="#{messages['lacewiki.button.dirDisplay.Delete']}"/>
- </h:outputLink>
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="linkClass" value="menuItemActionLink"/>
+ <ui:param name="labelClass" value="menuItemActionLabel"/>
+ <ui:param name="label" value="#{messages['lacewiki.button.dirDisplay.Delete']}"/>
+ <ui:param name="jsFunctionName" value="deleteDocumentId#{node.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(node.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="directoryBrowser, messageBoxContainer"
+ action="#{documentHome.remove(node.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</li>
</s:fragment>
+
<s:fragment rendered="#{s:hasPermission('Node', 'edit', node)}">
<li>
<s:link view="/docEdit_#{skin}.xhtml" propagation="none">
@@ -255,16 +266,27 @@
<h:outputText value="#{messages['lacewiki.button.dirDisplay.ViewNewWindow']}"/>
</h:outputLink>
</li>
+
<s:fragment rendered="#{directoryBrowser.isRemovable(node)}">
- <a:jsFunction name="deleteUploadId#{node.id}"
- status="globalStatus"
- action="#{uploadHome.remove(node.id)}"/>
<li>
- <h:outputLink value="javascript:deleteConfirmation('\\'#{node.name}\\'','deleteUploadId#{node.id}')">
- <h:outputText value="#{messages['lacewiki.button.dirDisplay.Delete']}"/>
- </h:outputLink>
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="linkClass" value="menuItemActionLink"/>
+ <ui:param name="labelClass" value="menuItemActionLabel"/>
+ <ui:param name="label" value="#{messages['lacewiki.button.dirDisplay.Delete']}"/>
+ <ui:param name="jsFunctionName" value="deleteUploadId#{node.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(node.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="directoryBrowser, messageBoxContainer"
+ action="#{uploadHome.remove(node.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</li>
</s:fragment>
+
<s:fragment rendered="#{s:hasPermission('Node', 'edit', node)}">
<li>
<s:link view="/uploadEdit_#{skin}.xhtml" propagation="none">
Modified: trunk/examples/wiki/view/dirEdit_d.xhtml
===================================================================
--- trunk/examples/wiki/view/dirEdit_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/dirEdit_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -241,15 +241,23 @@
</h:commandLink>
<s:fragment rendered="#{directoryHome.removable}">
- <a:jsFunction name="deleteDirectory"
- status="globalStatus"
- action="#{directoryHome.remove}"/>
- <h:outputLink tabindex="1"
- accesskey="#{messages['lacewiki.button.dirEdit.Delete.accesskey']}"
- value="javascript:deleteConfirmation('\\'#{directoryHome.instance.name}\\'','deleteDirectory')"
- styleClass="button sessionEventTrigger">
- <h:outputText escape="false" styleClass="buttonLabel" value="#{messages['lacewiki.button.dirEdit.Delete']}"/>
- </h:outputLink>
+
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.dirEdit.Delete']}"/>
+ <ui:param name="accesskey" value="#{messages['lacewiki.button.dirEdit.Delete.accesskey']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="deleteDirectory"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(directoryHome.instance.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{directoryHome.remove}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+
</s:fragment>
</div>
Modified: trunk/examples/wiki/view/docDisplay_d.xhtml
===================================================================
--- trunk/examples/wiki/view/docDisplay_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/docDisplay_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -221,15 +221,24 @@
</s:fragment>
- <s:fragment rendered="#{s:hasPermission('Comment', 'delete', currentDocument) and not commentHome.showForm}">
- <a:jsFunction name="deleteCommentId#{c.id}"
- reRender="commentDisplayForm"
- status="globalStatus"
- action="#{commentHome.remove(c.id)}"/>
- <h:outputLink value="javascript:deleteConfirmation('#{messages['lacewiki.label.commentsDisplay.CommentThread']} \\'#{c.subject}\\'','deleteCommentId#{c.id}')"
- styleClass="button">
- <h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
- </h:outputLink>
+ <s:fragment rendered="#{s:hasPermission('Comment', 'delete', currentDocument) and not commentHome.showForm}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
+ <ui:param name="jsFunctionName" value="deleteCommentId#{c.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(' ')
+ .concat(messages['lacewiki.label.commentsDisplay.CommentThread'])
+ .concat(': \'')
+ .concat(c.subject)
+ .concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="commentDisplayForm, messageBoxContainer"
+ action="#{commentHome.remove(c.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
</h:panelGroup>
Modified: trunk/examples/wiki/view/docEdit_d.xhtml
===================================================================
--- trunk/examples/wiki/view/docEdit_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/docEdit_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -332,15 +332,21 @@
</h:commandLink>
<s:fragment rendered="#{documentHome.removable}">
- <a:jsFunction name="deleteDocument"
- status="globalStatus"
- action="#{documentHome.remove}"/>
- <h:outputLink tabindex="1"
- accesskey="#{messages['lacewiki.button.docEdit.Delete.accesskey']}"
- value="javascript:deleteConfirmation('\\'#{documentHome.instance.name}\\'','deleteDocument')"
- styleClass="button sessionEventTrigger">
- <h:outputText escape="false" styleClass="buttonLabel" value="#{messages['lacewiki.button.docEdit.Delete']}"/>
- </h:outputLink>
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.docEdit.Delete']}"/>
+ <ui:param name="accesskey" value="#{messages['lacewiki.button.docEdit.Delete.accesskey']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="deleteDocument"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(documentHome.instance.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{documentHome.remove}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
</div>
Added: trunk/examples/wiki/view/includes/confirmationAction.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/confirmationAction.xhtml (rev 0)
+++ trunk/examples/wiki/view/includes/confirmationAction.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -0,0 +1,19 @@
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:wiki="http://jboss.com/products/seam/wiki"
+ xmlns:a="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+<ui:insert name="jsFunction"/>
+
+<h:outputLink value="javascript://no-op"
+ onclick="actionConfirmation( '#{wiki:escapeJSMessage(message)}' , '#{jsFunctionName}' )"
+ accesskey="#{accesskey}"
+ tabindex="#{tabindex}"
+ styleClass="#{not empty linkClass ? linkClass : 'button'}">
+ <h:outputText escape="#{not empty escapeLabel ? escapeLabel : 'true'}" styleClass="#{not empty labelClass ? labelClass : 'buttonLabel'}" value="#{label}"/>
+</h:outputLink>
+
+</ui:composition>
Modified: trunk/examples/wiki/view/includes/userControl.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/userControl.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/includes/userControl.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -97,7 +97,7 @@
<s:span styleClass="label">
<h:outputText value="#{messages['lacewiki.label.userControl.Password']} "/>
- <h:outputLink value="#" id="openPasswordResetPopup" tabindex="50">
+ <h:outputLink value="#" id="openPasswordResetPopup" tabindex="51">
<h:outputText styleClass="linkText" escape="false" value="(#{messages['lacewiki.button.userControl.ResetPassword']})"/>
</h:outputLink>
<h:outputText value=":"/>
Modified: trunk/examples/wiki/view/plugins/forumList/forumForm.xhtml
===================================================================
--- trunk/examples/wiki/view/plugins/forumList/forumForm.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/plugins/forumList/forumForm.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -72,16 +72,22 @@
<s:fragment rendered="#{forumHome.removable}">
- <a:jsFunction name="deleteForum"
- reRender="forumListPluginContainer, messageBoxContainer"
- status="globalStatus"
- action="#{forumHome.remove}"/>
- <h:outputLink tabindex="1"
- accesskey="#{messages['forum.button.Remove.accesskey']}"
- value="javascript:deleteConfirmation('\\'#{forumHome.instance.name}\\'','deleteForum')"
- styleClass="button saveButton sessionEventTrigger">
- <h:outputText escape="false" styleClass="buttonLabel" value="#{messages['forum.button.Remove']}"/>
- </h:outputLink>
+ <ui:decorate template="../../includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['forum.button.Remove']}"/>
+ <ui:param name="accesskey" value="#{messages['forum.button.Remove.accesskey']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger saveButton"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="deleteForum"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(forumHome.instance.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="forumListPluginContainer, messageBoxContainer"
+ action="#{forumHome.remove}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
<a:commandLink action="#{forumHome.persist}" rendered="#{!forumHome.managed}"
Modified: trunk/examples/wiki/view/plugins/forumReplies/plugin.xhtml
===================================================================
--- trunk/examples/wiki/view/plugins/forumReplies/plugin.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/plugins/forumReplies/plugin.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -139,14 +139,23 @@
</s:fragment>
<s:fragment rendered="#{s:hasPermission('Comment', 'delete', currentDocument) and not replyHome.showForm}">
- <a:jsFunction name="deleteReplyId#{c.id}"
- reRender="forumRepliesContainer"
- status="globalStatus"
- action="#{replyHome.remove(c.id)}"/>
- <h:outputLink value="javascript:deleteConfirmation('#{messages['lacewiki.label.commentsDisplay.CommentThread']} \\'#{c.subject}\\'','deleteReplyId#{c.id}')"
- styleClass="button sessionEventTrigger">
- <h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
- </h:outputLink>
+ <ui:decorate template="../../includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
+ <ui:param name="jsFunctionName" value="deleteReplyId#{c.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(' ')
+ .concat(messages['lacewiki.label.commentsDisplay.CommentThread'])
+ .concat(': \'')
+ .concat(c.subject)
+ .concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="forumRepliesContainer, messageBoxContainer"
+ action="#{replyHome.remove(c.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
</s:fragment>
Modified: trunk/examples/wiki/view/themes/default/js/lacewiki.js
===================================================================
--- trunk/examples/wiki/view/themes/default/js/lacewiki.js 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/default/js/lacewiki.js 2008-04-09 09:44:49 UTC (rev 7884)
@@ -39,6 +39,12 @@
// ###################### Form helpers #################################
+function actionConfirmation(message, actionFunctionName) {
+ if (confirm(message)) {
+ eval(actionFunctionName+"()");
+ }
+}
+
function onAjaxRequestComplete() {
resetSessionTimeoutCheck();
wrapBoxes();
Modified: trunk/examples/wiki/view/themes/default/template.xhtml
===================================================================
--- trunk/examples/wiki/view/themes/default/template.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/default/template.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -71,15 +71,6 @@
// ###################### Popups #################################
- function deleteConfirmation(message, deleteFunction) {
- var answer = confirm("#{messages['lacewiki.label.AreYouSureYouWantToDelete']} "
- + message
- + " #{messages['lacewiki.label.DeleteAllChildren']}");
- if (answer){
- eval(deleteFunction+"()");
- }
- }
-
var fadeInPopupDialog = function(hash) {
hash.w.fadeIn('fast',function(){ hash.o.show(); });
jQuery(".closeDialog", hash.w).attr("accesskey", "#{messages['lacewiki.button.Cancel.accesskey']}"); // Dynamically assign accesskey to .closeDialog buttons
Modified: trunk/examples/wiki/view/themes/inrelationto/js/lacewiki.js
===================================================================
--- trunk/examples/wiki/view/themes/inrelationto/js/lacewiki.js 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/inrelationto/js/lacewiki.js 2008-04-09 09:44:49 UTC (rev 7884)
@@ -39,6 +39,12 @@
// ###################### Form helpers #################################
+function actionConfirmation(message, actionFunctionName) {
+ if (confirm(message)) {
+ eval(actionFunctionName+"()");
+ }
+}
+
function onAjaxRequestComplete() {
resetSessionTimeoutCheck();
wrapBoxes();
Modified: trunk/examples/wiki/view/themes/inrelationto/template.xhtml
===================================================================
--- trunk/examples/wiki/view/themes/inrelationto/template.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/inrelationto/template.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -61,15 +61,6 @@
// ###################### Popups #################################
- function deleteConfirmation(message, deleteFunction) {
- var answer = confirm("#{messages['lacewiki.label.AreYouSureYouWantToDelete']} "
- + message
- + " #{messages['lacewiki.label.DeleteAllChildren']}");
- if (answer){
- eval(deleteFunction+"()");
- }
- }
-
var fadeInPopupDialog = function(hash) {
hash.w.fadeIn('fast',function(){ hash.o.show(); });
jQuery(".closeDialog", hash.w).attr("accesskey", "#{messages['lacewiki.button.Cancel.accesskey']}"); // Dynamically assign accesskey to .closeDialog buttons
Modified: trunk/examples/wiki/view/themes/sfwkorg/js/lacewiki.js
===================================================================
--- trunk/examples/wiki/view/themes/sfwkorg/js/lacewiki.js 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/sfwkorg/js/lacewiki.js 2008-04-09 09:44:49 UTC (rev 7884)
@@ -39,6 +39,12 @@
// ###################### Form helpers #################################
+function actionConfirmation(message, actionFunctionName) {
+ if (confirm(message)) {
+ eval(actionFunctionName+"()");
+ }
+}
+
function onAjaxRequestComplete() {
resetSessionTimeoutCheck();
wrapBoxes();
Modified: trunk/examples/wiki/view/themes/sfwkorg/template.xhtml
===================================================================
--- trunk/examples/wiki/view/themes/sfwkorg/template.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/themes/sfwkorg/template.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -62,15 +62,6 @@
// ###################### Popups #################################
- function deleteConfirmation(message, deleteFunction) {
- var answer = confirm("#{messages['lacewiki.label.AreYouSureYouWantToDelete']} "
- + message
- + " #{messages['lacewiki.label.DeleteAllChildren']}");
- if (answer){
- eval(deleteFunction+"()");
- }
- }
-
var fadeInPopupDialog = function(hash) {
hash.w.fadeIn('fast',function(){ hash.o.show(); });
jQuery(".closeDialog", hash.w).attr("accesskey", "#{messages['lacewiki.button.Cancel.accesskey']}"); // Dynamically assign accesskey to .closeDialog buttons
Modified: trunk/examples/wiki/view/uploadEdit_d.xhtml
===================================================================
--- trunk/examples/wiki/view/uploadEdit_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/uploadEdit_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -141,15 +141,21 @@
</h:commandLink>
<s:fragment rendered="#{uploadHome.removable}">
- <a:jsFunction name="deleteUpload"
- status="globalStatus"
- action="#{uploadHome.remove}"/>
- <h:outputLink tabindex="1"
- accesskey="#{messages['lacewiki.button.uploadEdit.Delete.accesskey']}"
- value="javascript:deleteConfirmation('\\'#{uploadHome.instance.name}\\'','deleteUpload')"
- styleClass="button sessionEventTrigger">
- <h:outputText escape="false" styleClass="buttonLabel" value="#{messages['lacewiki.button.uploadEdit.Delete']}"/>
- </h:outputLink>
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.uploadEdit.Delete']}"/>
+ <ui:param name="accesskey" value="#{messages['lacewiki.button.uploadEdit.Delete.accesskey']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="deleteUpload"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(uploadHome.instance.name).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{uploadHome.remove}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
</div>
Modified: trunk/examples/wiki/view/userHome_d.xhtml
===================================================================
--- trunk/examples/wiki/view/userHome_d.xhtml 2008-04-09 09:16:02 UTC (rev 7883)
+++ trunk/examples/wiki/view/userHome_d.xhtml 2008-04-09 09:44:49 UTC (rev 7884)
@@ -317,15 +317,21 @@
</h:commandLink>
<s:fragment rendered="#{s:hasPermission('User', 'delete', userHome.instance)}">
- <a:jsFunction name="deleteUser"
- status="globalStatus"
- action="#{userHome.remove}"/>
- <h:outputLink tabindex="1"
- accesskey="#{messages['lacewiki.button.userHome.Delete.accesskey']}"
- value="javascript:deleteConfirmation('\\'#{userHome.instance.username}\\'','deleteUser')"
- styleClass="button sessionEventTrigger">
- <h:outputText escape="false" styleClass="buttonLabel" value="#{messages['lacewiki.button.userHome.Delete']}"/>
- </h:outputLink>
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.button.userHome.Delete']}"/>
+ <ui:param name="accesskey" value="#{messages['lacewiki.button.userHome.Delete.accesskey']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button sessionEventTrigger"/>
+ <ui:param name="escapeLabel" value="false"/>
+ <ui:param name="jsFunctionName" value="deleteUser"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
+ .concat(': \'').concat(userHome.instance.username).concat('\'?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{userHome.remove}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
</s:fragment>
</div>
16 years, 7 months
Seam SVN: r7883 - trunk/src/main/org/jboss/seam/security/management/action.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-09 05:16:02 -0400 (Wed, 09 Apr 2008)
New Revision: 7883
Modified:
trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java
Log:
fix wiki
Modified: trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java 2008-04-09 04:53:19 UTC (rev 7882)
+++ trunk/src/main/org/jboss/seam/security/management/action/UserSearch.java 2008-04-09 09:16:02 UTC (rev 7883)
@@ -14,7 +14,7 @@
import org.jboss.seam.security.management.IdentityManager;
-@Name("userSearch")
+//@Name("userSearch")
@Scope(SESSION)
@Synchronized
public class UserSearch implements Serializable
16 years, 7 months
Seam SVN: r7882 - in trunk/src/main/org/jboss/seam/security: permission and 2 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-09 00:53:19 -0400 (Wed, 09 Apr 2008)
New Revision: 7882
Added:
trunk/src/main/org/jboss/seam/security/permission/Permission.java
trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaDynamicPermissionStore.java
Removed:
trunk/src/main/org/jboss/seam/security/permission/AccountType.java
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java
Modified:
trunk/src/main/org/jboss/seam/security/Identity.java
trunk/src/main/org/jboss/seam/security/Role.java
trunk/src/main/org/jboss/seam/security/SimplePrincipal.java
trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java
Log:
more refactoring
Modified: trunk/src/main/org/jboss/seam/security/Identity.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/Identity.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/Identity.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -395,7 +395,7 @@
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
- return sg.isMember( new SimplePrincipal(role) );
+ return sg.isMember( new Role(role) );
}
}
return false;
@@ -424,12 +424,12 @@
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
- return sg.addMember(new SimplePrincipal(role));
+ return sg.addMember(new Role(role));
}
}
SimpleGroup roleGroup = new SimpleGroup(ROLES_GROUP);
- roleGroup.addMember(new SimplePrincipal(role));
+ roleGroup.addMember(new Role(role));
getSubject().getPrincipals().add(roleGroup);
return true;
}
Modified: trunk/src/main/org/jboss/seam/security/Role.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/Role.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/Role.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,23 +1,14 @@
package org.jboss.seam.security;
-import java.io.Serializable;
-
/**
- * Represents a user role exclusively within the scope of security rules.
+ * Represents a user role
*
* @author Shane Bryzak
*/
-public class Role implements Serializable
-{
- private String name;
-
+public class Role extends SimplePrincipal
+{
public Role(String name)
{
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
+ super(name);
+ }
}
Modified: trunk/src/main/org/jboss/seam/security/SimplePrincipal.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/SimplePrincipal.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/SimplePrincipal.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -43,7 +43,7 @@
@Override
public int hashCode()
{
- return name==null ? 0 : name.hashCode();
+ return name != null ? name.hashCode() : super.hashCode();
}
@Override
Deleted: trunk/src/main/org/jboss/seam/security/permission/AccountType.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AccountType.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/AccountType.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,7 +0,0 @@
-package org.jboss.seam.security.permission;
-
-public enum AccountType
-{
- user,
- role
-}
Added: trunk/src/main/org/jboss/seam/security/permission/Permission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/Permission.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/Permission.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -0,0 +1,46 @@
+package org.jboss.seam.security.permission;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+/**
+ * Base class for permissions
+ *
+ * @author Shane Bryzak
+ */
+public class Permission implements Serializable
+{
+ private Object target;
+ private String action;
+ private Principal recipient;
+
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(Object target)
+ {
+ this.target = target;
+ }
+
+ public String getAction()
+ {
+ return action;
+ }
+
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+ public Principal getRecipient()
+ {
+ return recipient;
+ }
+
+ public void setRecipient(Principal recipient)
+ {
+ this.recipient = recipient;
+ }
+}
Modified: trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -16,10 +16,7 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.permission.acl.AclPermission;
-import org.jboss.seam.security.permission.acl.AclPermissionStore;
-import org.jboss.seam.security.permission.dynamic.AccountPermission;
-import org.jboss.seam.security.permission.dynamic.AccountPermissionStore;
+import org.jboss.seam.security.permission.PermissionStore;
/**
* Permission management component, used to grant or revoke permissions on specific objects or of
@@ -43,19 +40,19 @@
private static final LogProvider log = Logging.getLogProvider(PermissionManager.class);
- private AccountPermissionStore accountPermissionStore;
+ private PermissionStore dynamicPermissionStore;
- private AclPermissionStore aclPermissionStore;
+ private PermissionStore aclPermissionStore;
@Create
public void create()
{
- if (accountPermissionStore == null)
+ if (dynamicPermissionStore == null)
{
- accountPermissionStore = (AccountPermissionStore) Component.getInstance(ACCOUNT_PERMISSION_STORE_COMPONENT_NAME, true);
+ dynamicPermissionStore = (PermissionStore) Component.getInstance(ACCOUNT_PERMISSION_STORE_COMPONENT_NAME, true);
}
- if (accountPermissionStore == null)
+ if (dynamicPermissionStore == null)
{
log.warn("no account permission store available - please install an AccountPermissionStore with the name '" +
ACCOUNT_PERMISSION_STORE_COMPONENT_NAME + "' if account-based permission management is required.");
@@ -63,7 +60,7 @@
if (aclPermissionStore == null)
{
- aclPermissionStore = (AclPermissionStore) Component.getInstance(ACL_PERMISSION_STORE_COMPONENT_NAME);
+ aclPermissionStore = (PermissionStore) Component.getInstance(ACL_PERMISSION_STORE_COMPONENT_NAME);
}
if (aclPermissionStore == null)
@@ -91,55 +88,59 @@
return instance;
}
- public AccountPermissionStore getAccountPermissionStore()
+ public PermissionStore getDynamicPermissionStore()
{
- return accountPermissionStore;
+ return dynamicPermissionStore;
}
- public void setAccountPermissionStore(AccountPermissionStore accountPermissionStore)
+ public void setDynamicPermissionStore(PermissionStore dynamicPermissionStore)
{
- this.accountPermissionStore = accountPermissionStore;
+ this.dynamicPermissionStore = dynamicPermissionStore;
}
- public List<AccountPermission> listPermissions(String target, String action)
+ public List<Permission> listPermissions(String target, String action)
{
Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_READ);
- return accountPermissionStore.listPermissions(target, action);
+ return dynamicPermissionStore.listPermissions(target, action);
}
- public List<AccountPermission> listPermissions(String target)
+ public List<Permission> listPermissions(String target)
{
Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_READ);
- return accountPermissionStore.listPermissions(target);
+ return dynamicPermissionStore.listPermissions(target);
}
- public List<AclPermission> listPermissions(Object target)
+ public List<Permission> listPermissions(Object target)
{
Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_READ);
return aclPermissionStore.listPermissions(target);
}
- public boolean grantPermission(String target, String action, String account, AccountType accountType)
+ public boolean grantPermission(Permission permission)
{
Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_GRANT);
- return accountPermissionStore.grantPermission(target, action, account, accountType);
+
+ if (permission.getTarget() instanceof String)
+ {
+ return dynamicPermissionStore.grantPermission(permission);
+ }
+ else
+ {
+ return aclPermissionStore.grantPermission(permission);
+ }
}
- public boolean grantPermission(Object target, String action, String account, AccountType accountType)
+ public boolean revokePermission(Permission permission)
{
- Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_GRANT);
- return aclPermissionStore.grantPermission(target, action, account, accountType);
- }
-
- public boolean revokePermission(String target, String action, String account, AccountType accountType)
- {
Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_REVOKE);
- return accountPermissionStore.revokePermission(target, action, account, accountType);
+
+ if (permission.getTarget() instanceof String)
+ {
+ return dynamicPermissionStore.revokePermission(permission);
+ }
+ else
+ {
+ return aclPermissionStore.revokePermission(permission);
+ }
}
-
- public boolean revokePermission(Object target, String action, String account, AccountType accountType)
- {
- Identity.instance().checkPermission(PERMISSION_PERMISSION_NAME, PERMISSION_REVOKE);
- return aclPermissionStore.revokePermission(target, action, account, accountType);
- }
}
Added: trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -0,0 +1,16 @@
+package org.jboss.seam.security.permission;
+
+import java.util.List;
+
+/**
+ * Permission store interface.
+ *
+ * @author Shane Bryzak
+ */
+public interface PermissionStore
+{
+ List<Permission> listPermissions(Object target);
+ List<Permission> listPermissions(Object target, String action);
+ boolean grantPermission(Permission permission);
+ boolean revokePermission(Permission permission);
+}
Deleted: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,21 +0,0 @@
-package org.jboss.seam.security.permission.acl;
-
-import org.jboss.seam.security.permission.AccountType;
-
-public abstract class AclPermission
-{
- public abstract String getObjectId();
- public abstract void setObjectId(String objectId);
-
- public abstract String getIdentifier();
- public abstract void setIdentifier(String identifier);
-
- public abstract String getAccount();
- public abstract void setAccount(String account);
-
- public abstract AccountType getAccountType();
- public abstract void setAccountType(AccountType accountType);
-
- public abstract long getPermissions();
- public abstract void setPermissions(long permissions);
-}
Modified: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -16,7 +16,8 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.permission.AccountType;
+import org.jboss.seam.security.permission.Permission;
+import org.jboss.seam.security.permission.PermissionStore;
import org.jboss.seam.security.permission.PermissionResolver;
@Name("org.jboss.seam.security.aclPermissionResolver")
@@ -28,7 +29,7 @@
{
private static final String DEFAULT_PERMISSION_STORE_NAME = "aclPermissionStore";
- private AclPermissionStore permissionStore;
+ private PermissionStore permissionStore;
private static final LogProvider log = Logging.getLogProvider(AclPermissionResolver.class);
@@ -42,7 +43,7 @@
{
if (permissionStore == null)
{
- permissionStore = (AclPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
+ permissionStore = (PermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
}
if (permissionStore == null)
@@ -56,7 +57,7 @@
{
if (permissionStore == null) return false;
- List<AclPermission> permissions = permissionStore.listPermissions(target);
+ List<Permission> permissions = permissionStore.listPermissions(target);
Identity identity = Identity.instance();
@@ -64,15 +65,15 @@
String username = identity.getPrincipal().getName();
- for (AclPermission permission : permissions)
+ for (Permission permission : permissions)
{
- if ((username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user)) ||
- (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount())))
+ if ((username.equals(permission.getRecipient())) ||
+ (identity.hasRole(permission.getRecipient().getName())))
{
- if (hasPermissionFlag(target, action, permission.getPermissions()))
- {
- return true;
- }
+// if (hasPermissionFlag(target, action, permission.getPermissions()))
+// {
+// return true;
+// }
}
}
Deleted: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,17 +0,0 @@
-package org.jboss.seam.security.permission.acl;
-
-import java.util.List;
-
-import org.jboss.seam.security.permission.AccountType;
-
-/**
- * Persistent storage for ACL (instance-based) permissions
- *
- * @author Shane Bryzak
- */
-public interface AclPermissionStore
-{
- List<AclPermission> listPermissions(Object target);
- boolean grantPermission(Object target, String action, String account, AccountType accountType);
- boolean revokePermission(Object target, String action, String account, AccountType accountType);
-}
Modified: trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -3,32 +3,43 @@
import java.io.Serializable;
import java.util.List;
-import org.jboss.seam.security.permission.AccountType;
+import org.jboss.seam.security.permission.Permission;
+import org.jboss.seam.security.permission.PermissionStore;
-public class JpaAclPermissionStore implements AclPermissionStore, Serializable
+/**
+ * ACL permission storage, using JPA
+ *
+ * @author Shane Bryzak
+ */
+public class JpaAclPermissionStore implements PermissionStore, Serializable
{
private String entityManagerName = "entityManager";
- private Class<? extends AclPermission> permissionClass;
+ private Class permissionClass;
protected String getIdentifier(Object target)
{
return null;
}
- public boolean grantPermission(Object target, String action, String account, AccountType accountType)
+ public boolean grantPermission(Permission permission)
{
// TODO Auto-generated method stub
return false;
}
- public List<AclPermission> listPermissions(Object target)
+ public List<Permission> listPermissions(Object target)
{
// TODO Auto-generated method stub
return null;
}
+
+ public List<Permission> listPermissions(Object target, String action)
+ {
+ return null;
+ }
- public boolean revokePermission(Object target, String action, String account, AccountType accountType)
+ public boolean revokePermission(Permission permission)
{
// TODO Auto-generated method stub
return false;
Deleted: trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.permission.dynamic;
-
-import org.jboss.seam.security.permission.AccountType;
-
-/**
- * Abstract base class for persistence of user/role permissions. This class should be extended
- * to create a concrete JPA/Hibernate implementation.
- *
- * @author Shane Bryzak
- */
-public abstract class AccountPermission
-{
- public abstract String getTarget();
- public abstract void setTarget(String target);
-
- public abstract String getAction();
- public abstract void setAction(String action);
-
- public abstract String getAccount();
- public abstract void setAccount(String account);
-
- public abstract AccountType getAccountType();
- public abstract void setAccountType(AccountType accountType);
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,19 +0,0 @@
-package org.jboss.seam.security.permission.dynamic;
-
-import java.util.List;
-
-import org.jboss.seam.security.permission.AccountType;
-
-/**
- * Persistent store for account-based (user/role) permissions
- *
- * @author Shane Bryzak
- */
-public interface AccountPermissionStore
-{
- List<AccountPermission> listPermissions(String target, String action);
- List<AccountPermission> listPermissions(String target);
-
- boolean grantPermission(String target, String action, String account, AccountType accountType);
- boolean revokePermission(String target, String action, String account, AccountType accountType);
-}
Modified: trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -17,12 +17,13 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.permission.AccountType;
+import org.jboss.seam.security.permission.Permission;
import org.jboss.seam.security.permission.PermissionResolver;
+import org.jboss.seam.security.permission.PermissionStore;
/**
- * Resolves dynamically-assigned permissions kept in a persistent store, such as a
- * database.
+ * Resolves dynamically-assigned permissions, mapped to a user or a role, and kept in persistent
+ * storage, such as a relational database.
*
* @author Shane Bryzak
*/
@@ -35,7 +36,7 @@
{
private static final String DEFAULT_PERMISSION_STORE_NAME = "accountPermissionStore";
- private AccountPermissionStore permissionStore;
+ private PermissionStore permissionStore;
private static final LogProvider log = Logging.getLogProvider(DynamicPermissionResolver.class);
@@ -49,7 +50,7 @@
{
if (permissionStore == null)
{
- permissionStore = (AccountPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
+ permissionStore = (PermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
}
if (permissionStore == null)
@@ -59,12 +60,12 @@
}
}
- public AccountPermissionStore getPermissionStore()
+ public PermissionStore getPermissionStore()
{
return permissionStore;
}
- public void setPermissionStore(AccountPermissionStore permissionStore)
+ public void setPermissionStore(PermissionStore permissionStore)
{
this.permissionStore = permissionStore;
}
@@ -83,18 +84,18 @@
targetName = target.getClass().getName();
}
- List<AccountPermission> permissions = permissionStore.listPermissions(targetName, action);
+ List<Permission> permissions = permissionStore.listPermissions(targetName, action);
String username = identity.getPrincipal().getName();
- for (AccountPermission permission : permissions)
+ for (Permission permission : permissions)
{
- if (username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user))
+ if (username.equals(permission.getRecipient()))
{
return true;
}
- if (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount()))
+ if (identity.hasRole(permission.getRecipient().getName()))
{
return true;
}
Deleted: trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -1,123 +0,0 @@
-package org.jboss.seam.security.permission.dynamic;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.security.permission.AccountType;
-
-/**
- * A permission store implementation that uses JPA as its persistence mechanism.
- *
- * @author Shane Bryzak
- */
-@Scope(APPLICATION)
-@BypassInterceptors
-public class JpaAccountPermissionStore implements AccountPermissionStore, Serializable
-{
- private String entityManagerName = "entityManager";
-
- private Class<? extends AccountPermission> permissionClass;
-
- public boolean grantPermission(String target, String action, String account,
- AccountType accountType)
- {
- try
- {
- if (permissionClass == null)
- {
- throw new RuntimeException("Could not grant permission, permissionClass not set");
- }
-
- AccountPermission permission = permissionClass.newInstance();
- permission.setTarget(target);
- permission.setAction(action);
- permission.setAccount(account);
- permission.setAccountType(accountType);
-
- getEntityManager().persist(permission);
-
- return true;
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Could not grant permission", ex);
- }
- }
-
- public boolean revokePermission(String target, String action,
- String account, AccountType accountType)
- {
- try
- {
- EntityManager em = getEntityManager();
-
- AccountPermission permission = (AccountPermission) em.createQuery(
- "from " + permissionClass.getName() +
- " where target = :target and action = :action and account = :account " +
- " and accountType = :accountType")
- .setParameter("target", target)
- .setParameter("action", "action")
- .setParameter("account", account)
- .setParameter("accountType", accountType)
- .getSingleResult();
-
- em.remove(permission);
- return true;
- }
- catch (NoResultException ex)
- {
- return false;
- }
- }
-
- public List<AccountPermission> listPermissions(String target, String action)
- {
- return getEntityManager().createQuery(
- "from " + permissionClass.getName() +
- " where target = :target and action = :action")
- .setParameter("target", target)
- .setParameter("action", action)
- .getResultList();
- }
-
- public List<AccountPermission> listPermissions(String target)
- {
- return getEntityManager().createQuery(
- "from " + permissionClass.getName() + " where target = :target")
- .setParameter("target", target)
- .getResultList();
- }
-
- private EntityManager getEntityManager()
- {
- return (EntityManager) Component.getInstance(entityManagerName);
- }
-
- public String getEntityManagerName()
- {
- return entityManagerName;
- }
-
- public void setEntityManagerName(String name)
- {
- this.entityManagerName = name;
- }
-
- public Class getPermissionClass()
- {
- return permissionClass;
- }
-
- public void setPermissionClass(Class permissionClass)
- {
- this.permissionClass = permissionClass;
- }
-}
Added: trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaDynamicPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaDynamicPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaDynamicPermissionStore.java 2008-04-09 04:53:19 UTC (rev 7882)
@@ -0,0 +1,120 @@
+package org.jboss.seam.security.permission.dynamic;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.security.permission.Permission;
+import org.jboss.seam.security.permission.PermissionStore;
+
+/**
+ * A permission store implementation that uses JPA as its persistence mechanism.
+ *
+ * @author Shane Bryzak
+ */
+@Scope(APPLICATION)
+@BypassInterceptors
+public class JpaDynamicPermissionStore implements PermissionStore, Serializable
+{
+ private String entityManagerName = "entityManager";
+
+ private Class permissionClass;
+
+ public boolean grantPermission(Permission permission)
+ {
+ try
+ {
+ if (permissionClass == null)
+ {
+ throw new RuntimeException("Could not grant permission, permissionClass not set");
+ }
+
+ Object instance = permissionClass.newInstance();
+// instance.setTarget(permission.getTarget());
+// instance.setAction(permission.getAction());
+// instance.setAccount(permission.getRecipient());
+
+ getEntityManager().persist(instance);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Could not grant permission", ex);
+ }
+ }
+
+ public boolean revokePermission(Permission permission)
+ {
+ try
+ {
+ EntityManager em = getEntityManager();
+
+ Object instance = em.createQuery(
+ "from " + permissionClass.getName() +
+ " where target = :target and action = :action and account = :account " +
+ " and accountType = :accountType")
+ .setParameter("target", permission.getTarget())
+ .setParameter("action", "action")
+ .setParameter("account", permission.getRecipient())
+ .getSingleResult();
+
+ em.remove(instance);
+ return true;
+ }
+ catch (NoResultException ex)
+ {
+ return false;
+ }
+ }
+
+ public List<Permission> listPermissions(Object target, String action)
+ {
+ return getEntityManager().createQuery(
+ "from " + permissionClass.getName() +
+ " where target = :target and action = :action")
+ .setParameter("target", target)
+ .setParameter("action", action)
+ .getResultList();
+ }
+
+ public List<Permission> listPermissions(Object target)
+ {
+ return getEntityManager().createQuery(
+ "from " + permissionClass.getName() + " where target = :target")
+ .setParameter("target", target)
+ .getResultList();
+ }
+
+ private EntityManager getEntityManager()
+ {
+ return (EntityManager) Component.getInstance(entityManagerName);
+ }
+
+ public String getEntityManagerName()
+ {
+ return entityManagerName;
+ }
+
+ public void setEntityManagerName(String name)
+ {
+ this.entityManagerName = name;
+ }
+
+ public Class getPermissionClass()
+ {
+ return permissionClass;
+ }
+
+ public void setPermissionClass(Class permissionClass)
+ {
+ this.permissionClass = permissionClass;
+ }
+}
16 years, 7 months
Seam SVN: r7881 - in trunk/src/main/org/jboss/seam/security/permission: acl and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-08 21:59:09 -0400 (Tue, 08 Apr 2008)
New Revision: 7881
Added:
trunk/src/main/org/jboss/seam/security/permission/acl/
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/
trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java
Removed:
trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java
trunk/src/main/org/jboss/seam/security/permission/AccountPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/AclPermission.java
trunk/src/main/org/jboss/seam/security/permission/AclPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/AclPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/JpaAccountPermissionStore.java
trunk/src/main/org/jboss/seam/security/permission/JpaAclPermissionStore.java
Modified:
trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java
trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java
trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java
trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
Log:
refactored
Deleted: trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/AccountPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,22 +0,0 @@
-package org.jboss.seam.security.permission;
-
-/**
- * Abstract base class for persistence of user/role permissions. This class should be extended
- * to create a concrete JPA/Hibernate implementation.
- *
- * @author Shane Bryzak
- */
-public abstract class AccountPermission
-{
- public abstract String getTarget();
- public abstract void setTarget(String target);
-
- public abstract String getAction();
- public abstract void setAction(String action);
-
- public abstract String getAccount();
- public abstract void setAccount(String account);
-
- public abstract AccountType getAccountType();
- public abstract void setAccountType(AccountType accountType);
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/AccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AccountPermissionStore.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/AccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,17 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import java.util.List;
-
-/**
- * Persistent store for account-based (user/role) permissions
- *
- * @author Shane Bryzak
- */
-public interface AccountPermissionStore
-{
- List<AccountPermission> listPermissions(String target, String action);
- List<AccountPermission> listPermissions(String target);
-
- boolean grantPermission(String target, String action, String account, AccountType accountType);
- boolean revokePermission(String target, String action, String account, AccountType accountType);
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/AclPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AclPermission.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/AclPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,19 +0,0 @@
-package org.jboss.seam.security.permission;
-
-public abstract class AclPermission
-{
- public abstract String getObjectId();
- public abstract void setObjectId(String objectId);
-
- public abstract String getIdentifier();
- public abstract void setIdentifier(String identifier);
-
- public abstract String getAccount();
- public abstract void setAccount(String account);
-
- public abstract AccountType getAccountType();
- public abstract void setAccountType(AccountType accountType);
-
- public abstract long getPermissions();
- public abstract void setPermissions(long permissions);
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/AclPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AclPermissionResolver.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/AclPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,87 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.security.Identity;
-
-@Name("org.jboss.seam.security.aclPermissionResolver")
-@Scope(APPLICATION)
-@BypassInterceptors
-@Install(precedence=FRAMEWORK)
-@Startup
-public class AclPermissionResolver implements PermissionResolver, Serializable
-{
- private static final String DEFAULT_PERMISSION_STORE_NAME = "aclPermissionStore";
-
- private AclPermissionStore permissionStore;
-
- private static final LogProvider log = Logging.getLogProvider(AclPermissionResolver.class);
-
- @Create
- public void create()
- {
- initPermissionStore();
- }
-
- protected void initPermissionStore()
- {
- if (permissionStore == null)
- {
- permissionStore = (AclPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
- }
-
- if (permissionStore == null)
- {
- log.warn("no permission store available - please install a PermissionStore with the name '" +
- DEFAULT_PERMISSION_STORE_NAME + "' if acl-based permissions are required.");
- }
- }
-
- public boolean hasPermission(Object target, String action)
- {
- if (permissionStore == null) return false;
-
- List<AclPermission> permissions = permissionStore.listPermissions(target);
-
- Identity identity = Identity.instance();
-
- if (!identity.isLoggedIn()) return false;
-
- String username = identity.getPrincipal().getName();
-
- for (AclPermission permission : permissions)
- {
- if ((username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user)) ||
- (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount())))
- {
- if (hasPermissionFlag(target, action, permission.getPermissions()))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- protected boolean hasPermissionFlag(Object target, String action, long permissions)
- {
- // TODO
-
- return false;
- }
-
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/AclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/AclPermissionStore.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/AclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,15 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import java.util.List;
-
-/**
- * Persistent storage for ACL (instance-based) permissions
- *
- * @author Shane Bryzak
- */
-public interface AclPermissionStore
-{
- List<AclPermission> listPermissions(Object target);
- boolean grantPermission(Object target, String action, String account, AccountType accountType);
- boolean revokePermission(Object target, String action, String account, AccountType accountType);
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/DynamicPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,103 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.FRAMEWORK;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.Seam;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-import org.jboss.seam.security.Identity;
-
-/**
- * Resolves dynamically-assigned permissions kept in a persistent store, such as a
- * database.
- *
- * @author Shane Bryzak
- */
-@Name("org.jboss.seam.security.dynamicPermissionResolver")
-@Scope(APPLICATION)
-@BypassInterceptors
-@Install(precedence=FRAMEWORK)
-@Startup
-public class DynamicPermissionResolver implements PermissionResolver, Serializable
-{
- private static final String DEFAULT_PERMISSION_STORE_NAME = "accountPermissionStore";
-
- private AccountPermissionStore permissionStore;
-
- private static final LogProvider log = Logging.getLogProvider(DynamicPermissionResolver.class);
-
- @Create
- public void create()
- {
- initPermissionStore();
- }
-
- protected void initPermissionStore()
- {
- if (permissionStore == null)
- {
- permissionStore = (AccountPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
- }
-
- if (permissionStore == null)
- {
- log.warn("no permission store available - please install a PermissionStore with the name '" +
- DEFAULT_PERMISSION_STORE_NAME + "' if dynamic permissions are required.");
- }
- }
-
- public AccountPermissionStore getPermissionStore()
- {
- return permissionStore;
- }
-
- public void setPermissionStore(AccountPermissionStore permissionStore)
- {
- this.permissionStore = permissionStore;
- }
-
- public boolean hasPermission(Object target, String action)
- {
- if (permissionStore == null) return false;
-
- Identity identity = Identity.instance();
-
- if (!identity.isLoggedIn()) return false;
-
- String targetName = Seam.getComponentName(target.getClass());
- if (targetName == null)
- {
- targetName = target.getClass().getName();
- }
-
- List<AccountPermission> permissions = permissionStore.listPermissions(targetName, action);
-
- String username = identity.getPrincipal().getName();
-
- for (AccountPermission permission : permissions)
- {
- if (username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user))
- {
- return true;
- }
-
- if (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount()))
- {
- return true;
- }
- }
-
- return false;
- }
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/JpaAccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/JpaAccountPermissionStore.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/JpaAccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,122 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import static org.jboss.seam.ScopeType.APPLICATION;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-
-/**
- * A permission store implementation that uses JPA as its persistence mechanism.
- *
- * @author Shane Bryzak
- */
-@Scope(APPLICATION)
-@BypassInterceptors
-public class JpaAccountPermissionStore implements AccountPermissionStore, Serializable
-{
- private String entityManagerName = "entityManager";
-
- private Class<? extends AccountPermission> permissionClass;
-
- public boolean grantPermission(String target, String action, String account,
- AccountType accountType)
- {
- try
- {
- if (permissionClass == null)
- {
- throw new RuntimeException("Could not grant permission, permissionClass not set");
- }
-
- AccountPermission permission = permissionClass.newInstance();
- permission.setTarget(target);
- permission.setAction(action);
- permission.setAccount(account);
- permission.setAccountType(accountType);
-
- getEntityManager().persist(permission);
-
- return true;
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Could not grant permission", ex);
- }
- }
-
- public boolean revokePermission(String target, String action,
- String account, AccountType accountType)
- {
- try
- {
- EntityManager em = getEntityManager();
-
- AccountPermission permission = (AccountPermission) em.createQuery(
- "from " + permissionClass.getName() +
- " where target = :target and action = :action and account = :account " +
- " and accountType = :accountType")
- .setParameter("target", target)
- .setParameter("action", "action")
- .setParameter("account", account)
- .setParameter("accountType", accountType)
- .getSingleResult();
-
- em.remove(permission);
- return true;
- }
- catch (NoResultException ex)
- {
- return false;
- }
- }
-
- public List<AccountPermission> listPermissions(String target, String action)
- {
- return getEntityManager().createQuery(
- "from " + permissionClass.getName() +
- " where target = :target and action = :action")
- .setParameter("target", target)
- .setParameter("action", action)
- .getResultList();
- }
-
- public List<AccountPermission> listPermissions(String target)
- {
- return getEntityManager().createQuery(
- "from " + permissionClass.getName() + " where target = :target")
- .setParameter("target", target)
- .getResultList();
- }
-
- private EntityManager getEntityManager()
- {
- return (EntityManager) Component.getInstance(entityManagerName);
- }
-
- public String getEntityManagerName()
- {
- return entityManagerName;
- }
-
- public void setEntityManagerName(String name)
- {
- this.entityManagerName = name;
- }
-
- public Class getPermissionClass()
- {
- return permissionClass;
- }
-
- public void setPermissionClass(Class permissionClass)
- {
- this.permissionClass = permissionClass;
- }
-}
Deleted: trunk/src/main/org/jboss/seam/security/permission/JpaAclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/JpaAclPermissionStore.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/JpaAclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,54 +0,0 @@
-package org.jboss.seam.security.permission;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class JpaAclPermissionStore implements AclPermissionStore, Serializable
-{
- private String entityManagerName = "entityManager";
-
- private Class<? extends AclPermission> permissionClass;
-
- protected String getIdentifier(Object target)
- {
- return null;
- }
-
- public boolean grantPermission(Object target, String action, String account, AccountType accountType)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public List<AclPermission> listPermissions(Object target)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean revokePermission(Object target, String action, String account, AccountType accountType)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public String getEntityManagerName()
- {
- return entityManagerName;
- }
-
- public void setEntityManagerName(String entityManagerName)
- {
- this.entityManagerName = entityManagerName;
- }
-
- public Class getPermissionClass()
- {
- return permissionClass;
- }
-
- public void setPermissionClass(Class permissionClass)
- {
- this.permissionClass = permissionClass;
- }
-}
Modified: trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionManager.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -16,7 +16,17 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.permission.acl.AclPermission;
+import org.jboss.seam.security.permission.acl.AclPermissionStore;
+import org.jboss.seam.security.permission.dynamic.AccountPermission;
+import org.jboss.seam.security.permission.dynamic.AccountPermissionStore;
+/**
+ * Permission management component, used to grant or revoke permissions on specific objects or of
+ * specific permission types to particular users or roles.
+ *
+ * @author Shane Bryzak
+ */
@Scope(APPLICATION)
@Name("org.jboss.seam.security.permissionManager")
@Install(precedence = BUILT_IN)
Modified: trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/PermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -1,5 +1,10 @@
package org.jboss.seam.security.permission;
+/**
+ * Implementations of this interface perform permission checks using a variety of methods.
+ *
+ * @author Shane Bryzak
+ */
public interface PermissionResolver
{
boolean hasPermission(Object target, String action);
Modified: trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/ResolverChain.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -9,6 +9,12 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+/**
+ * A chain of permission resolvers. Specific permission checks are generally mapped to a
+ * particular ResolverChain for resolution.
+ *
+ * @author Shane Bryzak
+ */
@Scope(SESSION)
@BypassInterceptors
public class ResolverChain implements Serializable
Modified: trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2008-04-08 18:45:20 UTC (rev 7880)
+++ trunk/src/main/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -32,6 +32,11 @@
import org.jboss.seam.security.Role;
import org.jboss.seam.security.management.JpaIdentityStore;
+/**
+ * A permission resolver that uses a Drools rule base to perform permission checks
+ *
+ * @author Shane Bryzak
+ */
@Name("org.jboss.seam.security.ruleBasedPermissionResolver")
@Scope(SESSION)
@BypassInterceptors
Added: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,21 @@
+package org.jboss.seam.security.permission.acl;
+
+import org.jboss.seam.security.permission.AccountType;
+
+public abstract class AclPermission
+{
+ public abstract String getObjectId();
+ public abstract void setObjectId(String objectId);
+
+ public abstract String getIdentifier();
+ public abstract void setIdentifier(String identifier);
+
+ public abstract String getAccount();
+ public abstract void setAccount(String account);
+
+ public abstract AccountType getAccountType();
+ public abstract void setAccountType(AccountType accountType);
+
+ public abstract long getPermissions();
+ public abstract void setPermissions(long permissions);
+}
Added: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,89 @@
+package org.jboss.seam.security.permission.acl;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.permission.AccountType;
+import org.jboss.seam.security.permission.PermissionResolver;
+
+@Name("org.jboss.seam.security.aclPermissionResolver")
+@Scope(APPLICATION)
+@BypassInterceptors
+@Install(precedence=FRAMEWORK)
+@Startup
+public class AclPermissionResolver implements PermissionResolver, Serializable
+{
+ private static final String DEFAULT_PERMISSION_STORE_NAME = "aclPermissionStore";
+
+ private AclPermissionStore permissionStore;
+
+ private static final LogProvider log = Logging.getLogProvider(AclPermissionResolver.class);
+
+ @Create
+ public void create()
+ {
+ initPermissionStore();
+ }
+
+ protected void initPermissionStore()
+ {
+ if (permissionStore == null)
+ {
+ permissionStore = (AclPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
+ }
+
+ if (permissionStore == null)
+ {
+ log.warn("no permission store available - please install a PermissionStore with the name '" +
+ DEFAULT_PERMISSION_STORE_NAME + "' if acl-based permissions are required.");
+ }
+ }
+
+ public boolean hasPermission(Object target, String action)
+ {
+ if (permissionStore == null) return false;
+
+ List<AclPermission> permissions = permissionStore.listPermissions(target);
+
+ Identity identity = Identity.instance();
+
+ if (!identity.isLoggedIn()) return false;
+
+ String username = identity.getPrincipal().getName();
+
+ for (AclPermission permission : permissions)
+ {
+ if ((username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user)) ||
+ (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount())))
+ {
+ if (hasPermissionFlag(target, action, permission.getPermissions()))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ protected boolean hasPermissionFlag(Object target, String action, long permissions)
+ {
+ // TODO
+
+ return false;
+ }
+
+}
Added: trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/AclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,17 @@
+package org.jboss.seam.security.permission.acl;
+
+import java.util.List;
+
+import org.jboss.seam.security.permission.AccountType;
+
+/**
+ * Persistent storage for ACL (instance-based) permissions
+ *
+ * @author Shane Bryzak
+ */
+public interface AclPermissionStore
+{
+ List<AclPermission> listPermissions(Object target);
+ boolean grantPermission(Object target, String action, String account, AccountType accountType);
+ boolean revokePermission(Object target, String action, String account, AccountType accountType);
+}
Added: trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/acl/JpaAclPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,56 @@
+package org.jboss.seam.security.permission.acl;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.seam.security.permission.AccountType;
+
+public class JpaAclPermissionStore implements AclPermissionStore, Serializable
+{
+ private String entityManagerName = "entityManager";
+
+ private Class<? extends AclPermission> permissionClass;
+
+ protected String getIdentifier(Object target)
+ {
+ return null;
+ }
+
+ public boolean grantPermission(Object target, String action, String account, AccountType accountType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<AclPermission> listPermissions(Object target)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean revokePermission(Object target, String action, String account, AccountType accountType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public String getEntityManagerName()
+ {
+ return entityManagerName;
+ }
+
+ public void setEntityManagerName(String entityManagerName)
+ {
+ this.entityManagerName = entityManagerName;
+ }
+
+ public Class getPermissionClass()
+ {
+ return permissionClass;
+ }
+
+ public void setPermissionClass(Class permissionClass)
+ {
+ this.permissionClass = permissionClass;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermission.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.permission.dynamic;
+
+import org.jboss.seam.security.permission.AccountType;
+
+/**
+ * Abstract base class for persistence of user/role permissions. This class should be extended
+ * to create a concrete JPA/Hibernate implementation.
+ *
+ * @author Shane Bryzak
+ */
+public abstract class AccountPermission
+{
+ public abstract String getTarget();
+ public abstract void setTarget(String target);
+
+ public abstract String getAction();
+ public abstract void setAction(String action);
+
+ public abstract String getAccount();
+ public abstract void setAccount(String account);
+
+ public abstract AccountType getAccountType();
+ public abstract void setAccountType(AccountType accountType);
+}
Added: trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/AccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,19 @@
+package org.jboss.seam.security.permission.dynamic;
+
+import java.util.List;
+
+import org.jboss.seam.security.permission.AccountType;
+
+/**
+ * Persistent store for account-based (user/role) permissions
+ *
+ * @author Shane Bryzak
+ */
+public interface AccountPermissionStore
+{
+ List<AccountPermission> listPermissions(String target, String action);
+ List<AccountPermission> listPermissions(String target);
+
+ boolean grantPermission(String target, String action, String account, AccountType accountType);
+ boolean revokePermission(String target, String action, String account, AccountType accountType);
+}
Added: trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/DynamicPermissionResolver.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,105 @@
+package org.jboss.seam.security.permission.dynamic;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.permission.AccountType;
+import org.jboss.seam.security.permission.PermissionResolver;
+
+/**
+ * Resolves dynamically-assigned permissions kept in a persistent store, such as a
+ * database.
+ *
+ * @author Shane Bryzak
+ */
+@Name("org.jboss.seam.security.dynamicPermissionResolver")
+@Scope(APPLICATION)
+@BypassInterceptors
+@Install(precedence=FRAMEWORK)
+@Startup
+public class DynamicPermissionResolver implements PermissionResolver, Serializable
+{
+ private static final String DEFAULT_PERMISSION_STORE_NAME = "accountPermissionStore";
+
+ private AccountPermissionStore permissionStore;
+
+ private static final LogProvider log = Logging.getLogProvider(DynamicPermissionResolver.class);
+
+ @Create
+ public void create()
+ {
+ initPermissionStore();
+ }
+
+ protected void initPermissionStore()
+ {
+ if (permissionStore == null)
+ {
+ permissionStore = (AccountPermissionStore) Component.getInstance(DEFAULT_PERMISSION_STORE_NAME, true);
+ }
+
+ if (permissionStore == null)
+ {
+ log.warn("no permission store available - please install a PermissionStore with the name '" +
+ DEFAULT_PERMISSION_STORE_NAME + "' if dynamic permissions are required.");
+ }
+ }
+
+ public AccountPermissionStore getPermissionStore()
+ {
+ return permissionStore;
+ }
+
+ public void setPermissionStore(AccountPermissionStore permissionStore)
+ {
+ this.permissionStore = permissionStore;
+ }
+
+ public boolean hasPermission(Object target, String action)
+ {
+ if (permissionStore == null) return false;
+
+ Identity identity = Identity.instance();
+
+ if (!identity.isLoggedIn()) return false;
+
+ String targetName = Seam.getComponentName(target.getClass());
+ if (targetName == null)
+ {
+ targetName = target.getClass().getName();
+ }
+
+ List<AccountPermission> permissions = permissionStore.listPermissions(targetName, action);
+
+ String username = identity.getPrincipal().getName();
+
+ for (AccountPermission permission : permissions)
+ {
+ if (username.equals(permission.getAccount()) && permission.getAccountType().equals(AccountType.user))
+ {
+ return true;
+ }
+
+ if (permission.getAccountType().equals(AccountType.role) && identity.hasRole(permission.getAccount()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
Added: trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/permission/dynamic/JpaAccountPermissionStore.java 2008-04-09 01:59:09 UTC (rev 7881)
@@ -0,0 +1,123 @@
+package org.jboss.seam.security.permission.dynamic;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.security.permission.AccountType;
+
+/**
+ * A permission store implementation that uses JPA as its persistence mechanism.
+ *
+ * @author Shane Bryzak
+ */
+@Scope(APPLICATION)
+@BypassInterceptors
+public class JpaAccountPermissionStore implements AccountPermissionStore, Serializable
+{
+ private String entityManagerName = "entityManager";
+
+ private Class<? extends AccountPermission> permissionClass;
+
+ public boolean grantPermission(String target, String action, String account,
+ AccountType accountType)
+ {
+ try
+ {
+ if (permissionClass == null)
+ {
+ throw new RuntimeException("Could not grant permission, permissionClass not set");
+ }
+
+ AccountPermission permission = permissionClass.newInstance();
+ permission.setTarget(target);
+ permission.setAction(action);
+ permission.setAccount(account);
+ permission.setAccountType(accountType);
+
+ getEntityManager().persist(permission);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Could not grant permission", ex);
+ }
+ }
+
+ public boolean revokePermission(String target, String action,
+ String account, AccountType accountType)
+ {
+ try
+ {
+ EntityManager em = getEntityManager();
+
+ AccountPermission permission = (AccountPermission) em.createQuery(
+ "from " + permissionClass.getName() +
+ " where target = :target and action = :action and account = :account " +
+ " and accountType = :accountType")
+ .setParameter("target", target)
+ .setParameter("action", "action")
+ .setParameter("account", account)
+ .setParameter("accountType", accountType)
+ .getSingleResult();
+
+ em.remove(permission);
+ return true;
+ }
+ catch (NoResultException ex)
+ {
+ return false;
+ }
+ }
+
+ public List<AccountPermission> listPermissions(String target, String action)
+ {
+ return getEntityManager().createQuery(
+ "from " + permissionClass.getName() +
+ " where target = :target and action = :action")
+ .setParameter("target", target)
+ .setParameter("action", action)
+ .getResultList();
+ }
+
+ public List<AccountPermission> listPermissions(String target)
+ {
+ return getEntityManager().createQuery(
+ "from " + permissionClass.getName() + " where target = :target")
+ .setParameter("target", target)
+ .getResultList();
+ }
+
+ private EntityManager getEntityManager()
+ {
+ return (EntityManager) Component.getInstance(entityManagerName);
+ }
+
+ public String getEntityManagerName()
+ {
+ return entityManagerName;
+ }
+
+ public void setEntityManagerName(String name)
+ {
+ this.entityManagerName = name;
+ }
+
+ public Class getPermissionClass()
+ {
+ return permissionClass;
+ }
+
+ public void setPermissionClass(Class permissionClass)
+ {
+ this.permissionClass = permissionClass;
+ }
+}
16 years, 7 months
Seam SVN: r7880 - trunk/examples/jee5/booking and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 14:45:20 -0400 (Tue, 08 Apr 2008)
New Revision: 7880
Modified:
branches/Seam_2_0/examples/jee5/booking/
branches/Seam_2_0/examples/jee5/booking/build.xml
trunk/examples/jee5/booking/build.xml
Log:
JBSEAM-2833
Property changes on: branches/Seam_2_0/examples/jee5/booking
___________________________________________________________________
Name: svn:ignore
+ exploded-archives
dist
Modified: branches/Seam_2_0/examples/jee5/booking/build.xml
===================================================================
--- branches/Seam_2_0/examples/jee5/booking/build.xml 2008-04-08 18:40:13 UTC (rev 7879)
+++ branches/Seam_2_0/examples/jee5/booking/build.xml 2008-04-08 18:45:20 UTC (rev 7880)
@@ -39,7 +39,7 @@
<include name="lib/hibernate-annotations.jar"/>
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
- <include name="lib/jboss-common-core.jar" />
+ <include name="examples/jpa/lib/jboss-archive-browsing.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/asm.jar"/>
<include name="lib/antlr.jar" />
Modified: trunk/examples/jee5/booking/build.xml
===================================================================
--- trunk/examples/jee5/booking/build.xml 2008-04-08 18:40:13 UTC (rev 7879)
+++ trunk/examples/jee5/booking/build.xml 2008-04-08 18:45:20 UTC (rev 7880)
@@ -39,7 +39,7 @@
<include name="lib/hibernate-annotations.jar"/>
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
- <include name="lib/jboss-common-core.jar" />
+ <include name="examples/jpa/lib/jboss-archive-browsing.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/asm.jar"/>
<include name="lib/antlr.jar" />
16 years, 7 months
Seam SVN: r7879 - trunk/examples/hibernate and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 14:40:13 -0400 (Tue, 08 Apr 2008)
New Revision: 7879
Modified:
branches/Seam_2_0/examples/hibernate/
branches/Seam_2_0/examples/hibernate/build-glassfish.xml
trunk/examples/hibernate/build-glassfish.xml
Log:
JBSEAM-2835
Property changes on: branches/Seam_2_0/examples/hibernate
___________________________________________________________________
Name: svn:ignore
- build
test-output
test-build
exploded-archives-jboss
dist-jboss
+ build
test-output
test-build
exploded-archives-jboss
dist-jboss
dist-jboss-embedded
exploded-archives-jboss-embedded
dist-glassfish
exploded-archives-glassfish
Modified: branches/Seam_2_0/examples/hibernate/build-glassfish.xml
===================================================================
--- branches/Seam_2_0/examples/hibernate/build-glassfish.xml 2008-04-08 18:28:12 UTC (rev 7878)
+++ branches/Seam_2_0/examples/hibernate/build-glassfish.xml 2008-04-08 18:40:13 UTC (rev 7879)
@@ -31,6 +31,7 @@
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
<include name="examples/jpa/lib/jboss-archive-browsing.jar" />
+ <include name="lib/asm.jar" />
<include name="lib/jboss-common-core.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/antlr.jar" />
Modified: trunk/examples/hibernate/build-glassfish.xml
===================================================================
--- trunk/examples/hibernate/build-glassfish.xml 2008-04-08 18:28:12 UTC (rev 7878)
+++ trunk/examples/hibernate/build-glassfish.xml 2008-04-08 18:40:13 UTC (rev 7879)
@@ -31,6 +31,7 @@
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
<include name="examples/jpa/lib/jboss-archive-browsing.jar" />
+ <include name="lib/asm.jar" />
<include name="lib/jboss-common-core.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/antlr.jar" />
16 years, 7 months
Seam SVN: r7878 - branches/Seam_2_0/examples/jpa.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 14:28:12 -0400 (Tue, 08 Apr 2008)
New Revision: 7878
Modified:
branches/Seam_2_0/examples/jpa/
Log:
ignores
Property changes on: branches/Seam_2_0/examples/jpa
___________________________________________________________________
Name: svn:ignore
- test-build
exploded-archives-jboss
dist-jboss
+ test-build
exploded-archives-jboss
dist-jboss
exploded-archives-glassfish
exploded-archives-jboss-embedded
dist-glassfish
dist-jboss-embedded
16 years, 7 months
Seam SVN: r7877 - trunk/examples/jpa and 1 other directory.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 14:27:22 -0400 (Tue, 08 Apr 2008)
New Revision: 7877
Modified:
branches/Seam_2_0/examples/jpa/build-glassfish.xml
trunk/examples/jpa/build-glassfish.xml
Log:
JBSEAM-2834
Modified: branches/Seam_2_0/examples/jpa/build-glassfish.xml
===================================================================
--- branches/Seam_2_0/examples/jpa/build-glassfish.xml 2008-04-08 17:24:42 UTC (rev 7876)
+++ branches/Seam_2_0/examples/jpa/build-glassfish.xml 2008-04-08 18:27:22 UTC (rev 7877)
@@ -31,6 +31,7 @@
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
<include name="examples/jpa/lib/jboss-archive-browsing.jar" />
+ <include name="lib/asm.jar" />
<include name="lib/jboss-common-core.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/antlr.jar" />
Modified: trunk/examples/jpa/build-glassfish.xml
===================================================================
--- trunk/examples/jpa/build-glassfish.xml 2008-04-08 17:24:42 UTC (rev 7876)
+++ trunk/examples/jpa/build-glassfish.xml 2008-04-08 18:27:22 UTC (rev 7877)
@@ -31,6 +31,7 @@
<include name="lib/hibernate-entitymanager.jar"/>
<include name="lib/hibernate-validator.jar"/>
<include name="examples/jpa/lib/jboss-archive-browsing.jar" />
+ <include name="lib/asm.jar" />
<include name="lib/jboss-common-core.jar" />
<include name="lib/cglib.jar"/>
<include name="lib/antlr.jar" />
16 years, 7 months
Seam SVN: r7876 - branches/Seam_2_0/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 13:24:42 -0400 (Tue, 08 Apr 2008)
New Revision: 7876
Modified:
branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Controls.xml
Log:
JBSEAM-2806
Modified: branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Controls.xml
===================================================================
--- branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Controls.xml 2008-04-08 15:10:51 UTC (rev 7875)
+++ branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/Controls.xml 2008-04-08 17:24:42 UTC (rev 7876)
@@ -2,870 +2,611 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<chapter id="controls">
- <title>Seam JSF controls</title>
- <para>
- Seam includes a number of JSF controls that are useful for working with
- Seam. These are intended to complement the built-in JSF controls, and
- controls from other third-party libraries. We recommend
- JBoss RichFaces, and Apache MyFaces Trinidad tag libraries for use with Seam.
- We do not recommend the use of the Tomahawk tag library.
- </para>
+ <title>Seam JSF controls</title>
+ <para>
+ Seam includes a number of JSF controls that are useful for working with
+ Seam. These are intended to complement the built-in JSF controls, and
+ controls from other third-party libraries. We recommend
+ JBoss RichFaces, and Apache MyFaces Trinidad tag libraries for use with Seam.
+ We do not recommend the use of the Tomahawk tag library.
+ </para>
- <section id="controls.tags">
- <title>Tags</title>
+ <section id="controls.tags">
+ <title>Tags</title>
- <para>
- To use these tags, define the "<literal>s</literal>" namespace in your page
- as follows (facelets only):
- </para>
+ <para>
+ To use these tags, define the "<literal>s</literal>" namespace in your page
+ as follows (facelets only):
+ </para>
- <programlisting role="XHTML"><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"
+ <programlisting role="XHTML"><![CDATA[<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib">]]></programlisting>
- <para>
- The ui example demonstrates the use of a number of these tags.
- </para>
-
- <table>
- <title>Seam JSF Control Reference</title>
-
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*" />
- <colspec colnum="2" colwidth="3*" />
-
- <tbody>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:button></literal>
- </para>
- </entry>
- <entry valign="top">
+ <para>
+ The ui example demonstrates the use of a number of these tags.
+ </para>
+
+ <section>
+ <title>Navigation Controls</title>
+
+ <section>
+ <title><literal><s:button></literal></title>
+
<para><emphasis>Description</emphasis></para>
+
<para>
- A button that supports invocation of an action with control
- over conversation propagation. <emphasis>Does not submit the form.</emphasis>
+ A button that supports invocation of an action with control over
+ conversation propagation. <emphasis>Does not submit the
+ form.</emphasis>
</para>
<para><emphasis>Attributes</emphasis></para>
+
<itemizedlist>
- <listitem>
- <para>
- <literal>value</literal> — the label.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>action</literal> — a method binding that specified
- the action listener.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>view</literal> — the JSF view id to link to.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>fragment</literal> — the fragment identifier to link to.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>disabled</literal> — is the link disabled?
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>propagation</literal> — determines the conversation
- propagation style: <literal>begin</literal>, <literal>join</literal>,
- <literal>nest</literal>, <literal>none</literal> or <literal>end</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>pageflow</literal> — a pageflow definition to begin.
- (This is only useful when <literal>propagation="begin"</literal> or
- <literal>propagation="join"</literal>.)
- </para>
- </listitem>
+ <listitem>
+ <para>
+ <literal>value</literal> — the label.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>action</literal> — a method binding that
+ specified the action
+ listener.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>view</literal> — the JSF view id to link to.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fragment</literal> — the fragment
+ identifier to link to.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>disabled</literal> — is the link disabled?
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>propagation</literal> — determines the
+ conversation propagation style: <literal>begin</literal>,
+ <literal>join</literal>, <literal>nest</literal>,
+ <literal>none</literal> or <literal>end</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>pageflow</literal> — a pageflow definition
+ to begin. (This is only useful when
+ <literal>propagation="begin"</literal> or
+ <literal>propagation="join"</literal> is used).
+ </para>
+ </listitem>
</itemizedlist>
+
<para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:button id="cancel" value="Cancel"
+
+ <programlisting role="XHTML"><![CDATA[<s:button id="cancel"
+ value="Cancel"
action="#{hotelBooking.cancel}"/>]]></programlisting>
<para>
- You can specify both <literal>view</literal> and <literal>action</literal>
- on <literal><s:link /></literal>. In this case, the action
- will be called once the redirect to the specified view has
- occured.
+ You can specify both <literal>view</literal> and
+ <literal>action</literal> on <literal><s:link /></literal>.
+ In this case, the action wil be called once the redirect to the
+ specified view has occured.
</para>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
+
+ </section>
+
+ <section>
+ <title><literal><s:conversationId></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
+
<para>
- <literal><s:cache></literal>
+ Add the conversation id to JSF link or button (e.g.
+ <literal><h:commandLink /></literal> ,
+ <literal><s:button /></literal>).
</para>
- </entry>
- <entry valign="top">
+
+ <para><emphasis>Attributes</emphasis></para>
+
+ <para>None</para>
+
+ </section>
+
+ <section>
+ <title><literal><s:taskId></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Cache the rendered page fragment using JBoss Cache. Note that
- <literal><s:cache></literal> actually uses the instance
- of JBoss Cache managed by the built-in <literal>pojoCache</literal>
- component.
+ Add the task id to an output link (or similar JSF control),
+ when the task is available via <literal>#{task}</literal>.
</para>
+
<para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>key</literal> — the key to cache rendered content,
- often a value expression. For example, if we were caching a page
- fragment that displays a document, we might use
- <literal>key="Document-#{document.id}"</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>enabled</literal> — a value expression that determines
- if the cache should be used.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>region</literal> — a JBoss Cache node to use (different
- nodes can have different expiry policies).
- </para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:cache key="entry-#{blogEntry.id}" region="pageFragments">
- <div class="blogEntry">
- <h3>#{blogEntry.title}</h3>
- <div>
- <s:formattedText value="#{blogEntry.body}"/>
- </div>
- <p>
- [Posted on 
- <h:outputText value="#{blogEntry.date}">
- <f:convertDateTime timezone="#{blog.timeZone}" locale="#{blog.locale}"
- type="both"/>
- </h:outputText>]
- </p>
- </div>
-</s:cache>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
<para>
- <literal><s:conversationId></literal>
+ None.
</para>
- </entry>
- <entry valign="top">
+
+ </section>
+
+ <section>
+ <title><literal><s:link></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Add the conversation id to JSF link or button (e.g. <literal><h:commandLink /></literal>, <literal><s:button /></literal>).
+ A link that supports invocation of an action with control over
+ conversation propagation. <emphasis>Does not submit the
+ form.</emphasis>
</para>
+
<para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>value</literal> — the label.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>action</literal> — a method binding that
+ specified the action listener.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>view</literal> — the JSF view id to link to.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fragment</literal> — the fragment identifier
+ to link to.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>disabled</literal> — is the link disabled?
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>propagation</literal> — determines the
+ conversation propagation style: <literal>begin</literal>,
+ <literal>join</literal>, <literal>nest</literal>,
+ <literal>none</literal> or <literal>end</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>pageflow</literal> — a pageflow definition
+ to begin. (This is only useful when using
+ <literal>propagation="begin"</literal> or
+ <literal>propagation="join"</literal>.)
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:link id="register" view="/register.xhtml"
+ value="Register New User"/>]]></programlisting>
<para>
- None.
+ You can specify both <literal>view</literal> and
+ <literal>action</literal> on <literal><s:link /></literal>.
+ In this case, the action will be called once the redirect to the
+ specified view has occured.
</para>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
+
+ </section>
+
+ <section>
+ <title><literal><s:conversationPropagation></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
<para>
- <literal><s:conversationPropagation></literal>
+ Customize the conversation propagation for a command link or button
+ (or similar JSF control). <emphasis>Facelets only.</emphasis>
</para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- Customize the conversation propagation for a command link or button
- (or similar JSF control). <emphasis>Facelets only.</emphasis>
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
+ <listitem>
<para>
<literal>type</literal> — determines the conversation
- propagation style: <literal>begin</literal>, <literal>join</literal>,
- <literal>nest</literal>, <literal>none</literal> or <literal>end</literal>.
+ propagation style: <literal>begin</literal>,
+ <literal>join</literal>, <literal>nest</literal>,
+ <literal>none</literal> or <literal>end</literal>.
</para>
- </listitem>
- <listitem>
+ </listitem>
+ <listitem>
<para>
- <literal>pageflow</literal> — a pageflow definition to begin.
- (This is only useful when <literal>propagation="begin"</literal> or
- <literal>propagation="join"</literal>.)
+ <literal>pageflow</literal> — a pageflow definition to
+ begin. (This is only useful when using
+ <literal>propagation="begin"</literal> or
+ <literal>propagation="join"</literal>.)
</para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<h:commandButton value="Apply" action="#{personHome.update}">
- <s:conversationPropagation type="join" />
+ </listitem>
+ </itemizedlist>
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<h:commandButton value="Apply" action="#{personHome.update}">
+ <s:conversationPropagation type="join" />
</h:commandButton>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para><literal><s:convertDateTime></literal></para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
+ </section>
+
+ <section>
+ <title>
+ <literal><s:defaultAction></literal>
+ </title>
+
<para>
- Perform date or time conversions in the Seam timezone.
+ <emphasis>Description</emphasis>
</para>
- <para><emphasis>Attributes</emphasis></para>
<para>
- None.
+ Specify the default action to run when the form is submitted using
+ the enter key.
</para>
+ <para>
+ Currently you can only nest it inside buttons (e.g.
+ <literal><h:commandButton /></literal>,
+ <literal><a:commandButton /></literal> or
+ <literal><tr:commandButton /></literal>).
+ </para>
+ <para>
+ You must specify an id on the action source. You can only have one
+ default action per form.
+ </para>
+
+ <para>
+ <emphasis>Attributes</emphasis>
+ </para>
+ <para>None.</para>
+
<para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<h:commandButton id="foo" value="Foo" action="#{manager.foo}">
+ <s:defaultAction />
+</h:commandButton>]]></programlisting>
+ </section>
+
+ </section>
+
+ <section>
+ <title>Converters and Validators</title>
+
+ <section>
+ <title><literal><s:convertDateTime></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
+ <para>Perform date or time conversions in the Seam timezone.</para>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <para>None.</para>
+
+ <para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<h:outputText value="#{item.orderDate}">
- <s:convertDateTime type="both" dateStyle="full"/>
+ <s:convertDateTime type="both" dateStyle="full"/>
</h:outputText>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para><literal><s:convertEntity></literal></para>
- </entry>
- <entry valign="top">
+
+ </section>
+
+ <section>
+ <title><literal><s:convertEntity></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Assigns an entity converter to the current component. This is primarily
- useful for radio button and dropdown controls.
+ Assigns an entity converter to the current component. This is
+ primarily useful for radio button and dropdown controls.
</para>
-
+
<para>
- The converter works with any managed entity which has an <literal>@Id</literal> annotation -
- either simple or composite.
+ The converter works with any managed entity which has an
+ <literal>@Id</literal>
+ annotation - either simple or composite.
</para>
-
+
<para><emphasis>Attributes</emphasis></para>
-
- <para>
- None.
- </para>
-
+ <para>None.</para>
+
<para><emphasis>Configuration</emphasis></para>
-
+
<para>
- You must use <emphasis>Seam managed transactions</emphasis> (see <xref linkend="persistence.seam-managed-transactions" />) with <literal><s:convertEntity /></literal>.
+ You must use <emphasis>Seam managed transactions</emphasis> (see
+ <xref linkend="persistence.seam-managed-transactions" />) with
+ <literal><s:convertEntity /></literal>.
</para>
-
+
<para>
- If your <emphasis>Managed Persistence Context</emphasis> isn't called
- <literal>entityManager</literal>, then you need to set it in components.xml:
+ If your <emphasis>Managed Persistence Context</emphasis> isn't
+ called <literal>entityManager</literal>, then you need to set it in
+ components.xml:
</para>
<programlisting role="XML"><![CDATA[<component name="org.jboss.seam.ui.EntityConverter">
- <property name="entityManager">#{em}</property>
+ <property name="entityManager">#{em}</property>
</component>]]></programlisting>
-
+
<para>
- If you are using a <emphasis>Managed Hibernate Session</emphasis>
- then you need to set it in components.xml:
+ If you are using a <emphasis>Managed Hibernate Session</emphasis>
+ then you need to set it in components.xml:
</para>
<programlisting role="XML"><![CDATA[<component name="org.jboss.seam.ui.EntityConverter">
- <property name="session">#{hibernateSession}</property>
+ <property name="session">#{hibernateSession}</property>
</component>]]></programlisting>
-
+
<para>
- If you want to use more than one entity manager with the entity
- converter, you can create a copy of the entity converter for each
- entity manager in components.xml:
+ If you want to use more than one entity manager with the entity
+ converter, you can create a copy of the entity converter for each
+ entity manager in components.xml:
</para>
-
+
<programlisting role="XML"><![CDATA[<component name="myEntityConverter" class="org.jboss.seam.ui.converter.EntityConverter">
- <property name="entityManager">#{em}</property>
+ <property name="entityManager">#{em}</property>
</component>]]></programlisting>
-
+
<programlisting role="XHTML"><![CDATA[<h:selectOneMenu value="#{person.continent}">
- <s:selectItems value="#{continents.resultList}" var="continent"
- label="#{continent.name}" />
- <f:converter converterId="myEntityConverter" />
+ <s:selectItems value="#{continents.resultList}" var="continent"
+ label="#{continent.name}" />
+ <f:converter converterId="myEntityConverter" />
</h:selectOneMenu>]]></programlisting>
-
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<h:selectOneMenu value="#{person.continent}" required="true">
- <s:selectItems value="#{continents.resultList}" var="continent"
- label="#{continent.name}"
- noSelectionLabel="Please Select..."/>
- <s:convertEntity />
+ <s:selectItems value="#{continents.resultList}" var="continent"
+ label="#{continent.name}"
+ noSelectionLabel="Please Select..."/>
+ <s:convertEntity />
</h:selectOneMenu>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para><literal><s:convertEnum></literal></para>
- </entry>
-
- <entry valign="top">
+ </section>
+
+ <section>
+ <title><literal><s:convertEnum></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Assigns an enum converter to the current component. This is primarily
- useful for radio button and dropdown controls.
+ Assigns an enum converter to the current component. This is
+ primarily useful for radio button and dropdown controls.
</para>
+
<para><emphasis>Attributes</emphasis></para>
- <para>
- None.
- </para>
+ <para>None.</para>
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<h:selectOneMenu value="#{person.honorific}">
- <s:selectItems value="#{honorifics}" var="honorific"
+ <s:selectItems value="#{honorifics}" var="honorific"
label="#{honorific.label}"
noSelectionLabel="Please select" />
- <s:convertEnum />
+ <s:convertEnum />
</h:selectOneMenu>]]></programlisting>
- </entry>
- </row>
+ </section>
+
+ <section>
+ <title><literal><s:validate></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
+ <para>
+ A non-visual control, validates a JSF input field against the
+ bound property using Hibernate Validator.
+ </para>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <para>
+ None.
+ </para>
+
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<h:inputText id="userName" required="true"
+ value="#{customer.userName}">
+ <s:validate />
+</h:inputText>
+<h:message for="userName" styleClass="error" />]]></programlisting>
+ </section>
+
+ <section>
+ <title><literal><s:validateAll></literal></title>
- <row>
- <entry valign="top">
+ <para><emphasis>Description</emphasis></para>
<para>
- <literal><s:decorate></literal>
+ A non-visual control, validates all child JSF input fields
+ against their bound properties using Hibernate Validator.
</para>
- </entry>
- <entry valign="top">
+
+ <para><emphasis>Attributes</emphasis></para>
+ <para>
+ None.
+ </para>
+
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:validateAll>
+ <div class="entry">
+ <h:outputLabel for="username">Username:</h:outputLabel>
+ <h:inputText id="username" value="#{user.username}"
+ required="true"/>
+ <h:message for="username" styleClass="error" />
+ </div>
+ <div class="entry">
+ <h:outputLabel for="password">Password:</h:outputLabel>
+ <h:inputSecret id="password" value="#{user.password}"
+ required="true"/>
+ <h:message for="password" styleClass="error" />
+ </div>
+ <div class="entry">
+ <h:outputLabel for="verify">Verify Password:</h:outputLabel>
+ <h:inputSecret id="verify" value="#{register.verify}"
+ required="true"/>
+ <h:message for="verify" styleClass="error" />
+ </div>
+</s:validateAll>]]></programlisting>
+
+ </section>
+
+ </section>
+
+ <section>
+ <title>Formatting</title>
+
+ <section>
+ <title><literal><s:decorate></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- "Decorate" a JSF input field when validation fails or when
- <literal>required="true"</literal> is set.
+ "Decorate" a JSF input field when validation fails or when
+ <literal>required="true"</literal> is set.
</para>
<para><emphasis>Attributes</emphasis></para>
<itemizedlist>
- <listitem>
- <para>
- <literal>template</literal> — the facelets template to use to decorate the component
+ <listitem>
+ <para>
+ <literal>template</literal> — the facelets template
+ to use to decorate the component
</para>
</listitem>
</itemizedlist>
<para>
- <literal>#{invalid}</literal> and <literal>#{required}</literal> are
- available inside <literal>s:decorate</literal>; <literal>#{required}</literal>
- evaluates to <literal>true</literal> if you have set the input component
- being decorated as required, and <literal>#{invalid}</literal> evaluates
- to <literal>true</literal> if a validation error occurs.
+ <literal>#{invalid}</literal> and <literal>#{required}</literal>
+ are available inside <literal>s:decorate</literal>;
+ <literal>#{required}</literal> evaluates to
+ <literal>true</literal> if you have set the input component being
+ decorated as required, and <literal>#{invalid}</literal>
+ evaluates to <literal>true</literal> if a validation error occurs.
</para>
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<s:decorate template="edit.xhtml">
- <ui:define name="label">Country:</ui:define>
- <h:inputText value="#{location.country}" required="true"/>
- </s:decorate>]]></programlisting>
- <programlisting role="XHTML"><![CDATA[<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:s="http://jboss.com/products/seam/taglib">
+ <ui:define name="label">Country:</ui:define>
+ <h:inputText value="#{location.country}" required="true"/>
+ </s:decorate>]]></programlisting>
+ <programlisting role="XHTML"><![CDATA[<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:s="http://jboss.com/products/seam/taglib">
- <div>
+ <div>
- <s:label styleClass="#{invalid?'error':''}">
- <ui:insert name="label"/>
- <s:span styleClass="required" rendered="#{required}">*</s:span>
- </s:label>
+ <s:label styleClass="#{invalid?'error':''}">
+ <ui:insert name="label"/>
+ <s:span styleClass="required" rendered="#{required}">*</s:span>
+ </s:label>
- <span class="#{invalid?'error':''}">
- <s:validateAll>
- <ui:insert/>
- </s:validateAll>
- </span>
+ <span class="#{invalid?'error':''}">
+ <s:validateAll>
+ <ui:insert/>
+ </s:validateAll>
+ </span>
- <s:message styleClass="error"/>
+ <s:message styleClass="error"/>
- </div>
+ </div>
</ui:composition>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:defaultAction></literal>
- </para>
- </entry>
- <entry valign="top">
+ </section>
+
+ <section>
+ <title><literal><s:div></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Specify the default action to run when the form is submitted using
- the enter key.
+ Render a HTML <literal><div></literal>.
</para>
- <para>
- Currently you can only nest it inside buttons (e.g.
- <literal><h:commandButton /></literal>,
- <literal><a:commandButton /></literal> or
- <literal><tr:commandButton /></literal>).
- </para>
- <para>
- You must specify an id on the action source. You can only have one
- default action per form.
- </para>
+
<para><emphasis>Attributes</emphasis></para>
<para>
- None.
+ None.
</para>
+
<para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<h:commandButton id="foo" value="Foo" action="#{manager.foo}">
- <s:defaultAction />
-</h:commandButton>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:div></literal>
- </para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- Render a HTML <literal><div></literal>.
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <para>
- None.
- </para>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:div rendered="#{selectedMember == null}">
- Sorry, but this member does not exist.
+ <programlisting role="XHTML"><![CDATA[<s:div rendered="#{selectedMember == null}">
+ Sorry, but this member does not exist.
</s:div>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:enumItem></literal>
- </para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- Creates a <literal>SelectItem</literal> from an enum value.
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>enumValue</literal> — the string representation of the enum
- value.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>label</literal> — the label to be used when rendering the <literal>SelectItem</literal>.
- </para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<h:selectOneRadio id="radioList"
- layout="lineDirection"
- value="#{newPayment.paymentFrequency}">
- <s:convertEnum />
- <s:enumItem enumValue="ONCE" label="Only Once" />
- <s:enumItem enumValue="EVERY_MINUTE" label="Every Minute" />
- <s:enumItem enumValue="HOURLY" label="Every Hour" />
- <s:enumItem enumValue="DAILY" label="Every Day" />
- <s:enumItem enumValue="WEEKLY" label="Every Week" />
-</h:selectOneRadio>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:fileUpload></literal>
- </para>
- </entry>
- <entry valign="top">
+ </section>
+
+ <section>
+ <title><literal><s:span></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Renders a file upload control. This control must be used within a form with
- an encoding type of <literal>multipart/form-data</literal>, i.e:
+ Render a HTML <literal><span></literal>.
</para>
-
- <programlisting role="XHTML"><![CDATA[<h:form enctype="multipart/form-data">]]></programlisting>
-
- <para>
- For multipart requests, the Seam Multipart servlet filter must also be configured
- in <literal>web.xml</literal>:
- </para>
-
- <programlisting role="XML"><![CDATA[<filter>
- <filter-name>Seam Filter</filter-name>
- <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
-</filter>
-
-<filter-mapping>
- <filter-name>Seam Filter</filter-name>
- <url-pattern>/*</url-pattern>
-</filter-mapping>]]></programlisting>
-
- <para><emphasis>Configuration</emphasis></para>
-
- <para>
- The following configuration options for multipart requests may be configured in components.xml:
- </para>
-
- <itemizedlist>
- <listitem>
- <para>
- <literal>createTempFiles</literal> — if this option is set to true, uploaded files are
- streamed to a temporary file instead of in memory.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>maxRequestSize</literal> — the maximum size of a file upload request, in bytes.
- </para>
- </listitem>
- </itemizedlist>
-
- <para>
- Here's an example:
- </para>
-
- <programlisting role="XML"><![CDATA[<component class="org.jboss.seam.web.MultipartFilter">
- <property name="createTempFiles">true</property>
- <property name="maxRequestSize">1000000</property>
-</component>]]></programlisting>
-
+
<para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>data</literal> — this value binding receives the binary file data.
- The receiving field should be declared as a <literal>byte[]</literal> or <literal>InputStream</literal> (required).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>contentType</literal> — this value binding receives the file's
- content type (optional).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>fileName</literal> — this value binding receives the filename (optional).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>fileSize</literal> — this value binding receives the file size (optional).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>accept</literal> — a comma-separated list of content types to accept,
- may not be supported by the browser. E.g. <literal>"images/png,images/jpg"</literal>,
- <literal>"images/*"</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>style</literal> — The control's style
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>styleClass</literal> — The control's style class
- </para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:fileUpload id="picture" data="#{register.picture}"
- accept="image/png"
- contentType="#{register.pictureContentType}" />]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para><literal><s:formattedText></literal></para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
<para>
- Outputs <emphasis>Seam Text</emphasis>, a rich text markup useful for blogs, wikis and
- other applications that might use rich text. See the Seam Text chapter for full usage.
+ None.
</para>
- <para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>value</literal> — an EL expression specifying the rich text markup to render.
- </para>
- </listitem>
- </itemizedlist>
+
<para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:formattedText value="#{blog.text}"/>]]></programlisting>
- <para><emphasis>Example</emphasis></para>
- <mediaobject>
- <imageobject role="fo" scalefit="1">
- <imagedata fileref="images/controls-seamtext.png" align="center"/>
- </imageobject>
- <imageobject role="html">
- <imagedata fileref="images/controls-seamtext.png" align="center"/>
- </imageobject>
- </mediaobject>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:fragment></literal>
- </para>
- </entry>
- <entry valign="top">
+ <programlisting role="XHTML"><![CDATA[<s:span styleClass="required" rendered="#{required}">*</s:span>]]></programlisting>
+
+ </section>
+
+ <section>
+ <title><literal><s:fragment></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- A non-rendering component useful for enabling/disabling rendering of it's children.
+ A non-rendering component useful for enabling/disabling rendering
+ of it's children.
</para>
+
<para><emphasis>Attributes</emphasis></para>
<para>
- None.
+ None.
</para>
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<s:fragment rendered="#{auction.highBidder ne null}">
- Current bid:
+ Current bid:
</s:fragment>]]></programlisting>
- </entry>
- </row>
+
+ </section>
+
+ <section>
+ <title><literal><s:label></literal></title>
- <row>
- <entry valign="top">
- <para>
- <literal><s:graphicImage></literal>
- </para>
- </entry>
- <entry valign="top">
<para><emphasis>Description</emphasis></para>
<para>
- An extended <literal><h:graphicImage></literal> that allows the image to be created in a Seam Component; further transforms
- can be applied to the image.
+ "Decorate" a JSF input field with the label. The label is placed
+ inside the HTML <literal><label></literal> tag, and is
+ associated with the nearest JSF input component. It is often
+ used with <literal><s:decorate></literal>.
</para>
- <para>
- All attributes for <literal><h:graphicImage></literal> are supported, as well as:
- </para>
<para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
+ <itemizedlist>
<listitem>
- <para>
- <literal>value</literal> — image to display. Can be a path <literal>String</literal>
- (loaded from the classpath), a <literal>byte[]</literal>, a <literal>java.io.File</literal>,
- a <literal>java.io.InputStream</literal> or a <literal>java.net.URL</literal>. Currently supported
- image formats are <literal>image/png</literal>, <literal>image/jpeg</literal> and <literal>image/gif</literal>.
- </para>
+ <para>
+ <literal>style</literal> — The control's style
+ </para>
</listitem>
- <listitem>
- <para>
- <literal>fileName</literal> — if not specified the served image will have a generated file name.
- If you want to name your file, you should specify it here. This name should be unique
- </para>
+ <listitem>
+ <para>
+ <literal>styleClass</literal> — The control's style class
+ </para>
</listitem>
- </itemizedlist>
- <para><emphasis>Transformations</emphasis></para>
- <para>
- To apply a transform to the image, you would nest a tag specifying the transform to apply. Seam currently supports these
- transforms:
- </para>
- <variablelist>
- <varlistentry>
- <term><literal><s:transformImageSize></literal></term>
- <listitem>
- <itemizedlist>
- <listitem>
- <para>
- <literal>width</literal> — new width of the image
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>height</literal> — new height of the image
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>maintainRatio</literal> — if <literal>true</literal>, and <emphasis>one</emphasis> of
- <literal>width</literal>/<literal>height</literal> are specified, the image will be resized with the
- dimension not specified being calculated to maintain the aspect ratio.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>factor</literal> — scale the image by the given factor
- </para>
- </listitem>
- </itemizedlist>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal><s:transformImageBlur></literal></term>
- <listitem>
- <itemizedlist>
- <listitem>
- <para>
- <literal>radius</literal> — perform a convolution blur with the given radius
- </para>
- </listitem>
- </itemizedlist>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><literal><s:transformImageType></literal></term>
- <listitem>
- <itemizedlist>
- <listitem>
- <para>
- <literal>contentType</literal> — alter the type of the image to either <literal>image/jpeg</literal> or <literal>image/png</literal>
- </para>
- </listitem>
- </itemizedlist>
- </listitem>
- </varlistentry>
- </variablelist>
-
- <para>
- It's easy to create your own transform - create a <literal>UIComponent</literal> which <literal>implements</literal>
- <literal>org.jboss.seam.ui.graphicImage.ImageTransform</literal>. Inside the <literal>applyTransform()</literal>method
- use <literal>image.getBufferedImage()</literal> to get the original image and <literal>image.setBufferedImage()</literal>
- to set your transformed image. Transforms are applied in the order specified in the view.
- </para>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:graphicImage rendered="#{auction.image ne null}"
- value="#{auction.image.data}">
- <s:transformImageSize width="200" maintainRatio="true"/>
-</s:graphicImage>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:label></literal>
- </para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- "Decorate" a JSF input field with the label. The label is placed inside
- the HTML <literal><label></literal> tag, and is associated with the
- nearest JSF input component. It is often used with <literal><s:decorate></literal>.
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>style</literal> — The control's style
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>styleClass</literal> — The control's style class
- </para>
- </listitem>
</itemizedlist>
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<s:label styleClass="label">
Country:
</s:label>
<h:inputText value="#{location.country}" required="true"/>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:link></literal>
- </para>
- </entry>
- <entry valign="top">
+ </section>
+
+ <section>
+ <title><literal><s:message></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- A link that supports invocation of an action with control over conversation
- propagation. <emphasis>Does not submit the form.</emphasis>
+ "Decorate" a JSF input field with the validation error message.
</para>
+
<para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>value</literal> — the label.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>action</literal> — a method binding that specified
- the action listener.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>view</literal> — the JSF view id to link to.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>fragment</literal> — the fragment identifier to link to.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>disabled</literal> — is the link disabled?
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>propagation</literal> — determines the conversation
- propagation style: <literal>begin</literal>, <literal>join</literal>,
- <literal>nest</literal>, <literal>none</literal> or <literal>end</literal>.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>pageflow</literal> — a pageflow definition to begin.
- (This is only useful when <literal>propagation="begin"</literal> or
- <literal>propagation="join"</literal>.)
- </para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:link id="register" view="/register.xhtml"
- value="Register New User"/>]]></programlisting>
<para>
- You can specify both <literal>view</literal> and <literal>action</literal>
- on <literal><s:link /></literal>. In this case, the action
- will be called once the redirect to the specified view has
- occured.
+ None.
</para>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:message></literal>
- </para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- "Decorate" a JSF input field with the validation error message.
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <para>
- None.
- </para>
+
<para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<f:facet name="afterInvalidField">
<s:span>
@@ -873,486 +614,579 @@
<s:message/>
</s:span>
</f:facet>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
- <para>
- <literal><s:remote></literal>
- </para>
- </entry>
- <entry valign="top">
+
+ </section>
+
+ </section>
+
+ <section>
+ <title>Seam Text</title>
+
+ <section>
+ <title><literal><s:validateFormattedText></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Generates the Javascript stubs required to use Seam Remoting.
+ Checks that the submitted value is valid Seam Text
</para>
+
<para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
- <listitem>
- <para>
- <literal>include</literal> — a comma-separated list of the component names (or fully qualified class names)
- for which to generate Seam Remoting Javascript stubs. See <xref linkend="remoting"/> for more details.
- </para>
- </listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:remote include="customerAction,accountAction,com.acme.MyBean"/>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
<para>
- <literal><s:selectDate></literal>
+ None.
</para>
- </entry>
- <entry valign="top">
+ </section>
+
+ <section>
+ <title><literal><s:formattedText></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- <emphasis>Deprecated. Use <literal><rich:calendar /></literal> instead.</emphasis>
+ Outputs <emphasis>Seam Text</emphasis>, a rich text markup useful
+ for blogs, wikis and other applications that might use rich text.
+ See the Seam Text chapter for full usage.
</para>
- <para>
- Displays a dynamic date picker component that selects a date for the specified input field.
- The body of the <literal>selectDate</literal> element should contain HTML elements, such as
- text or an image, that prompt the user to click to display the date picker. The date picker
- <emphasis>must</emphasis> be styled using CSS. An example CSS file can be found in the Seam
- booking demo as <literal>date.css</literal>, or can be generated using seam-gen. The CSS
- styles used to control the appearance of the date picker are also described below.
- </para>
-
+
<para><emphasis>Attributes</emphasis></para>
<itemizedlist>
<listitem>
- <para>
- <literal>for</literal> — The id of the input field that the date picker will insert the
- selected date into.
- </para>
+ <para>
+ <literal>value</literal> — an EL expression specifying
+ the rich text markup to render.
+ </para>
</listitem>
- <listitem>
- <para>
- <literal>dateFormat</literal> — The date format string. This should match the date format of the
- input field.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>startYear</literal> — The popup year selector range will start at this year.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>endYear</literal> — The popup year selector range will end at this year.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>firstDayOfWeek</literal> — Controls which day is the first day of the week
- (0 = Sunday, 6 = Saturday). If this attribute is not set, then the first day of the week will
- default based on the user's locale.
- </para>
- </listitem>
</itemizedlist>
-
+
<para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:formattedText value="#{blog.text}"/>]]></programlisting>
- <programlisting role="XHTML"><![CDATA[<div class="row">
- <h:outputLabel for="dob">Date of birth<em>*</em></h:outputLabel>
- <h:inputText id="dob" value="#{user.dob}" required="true">
- <s:convertDateTime pattern="MM/dd/yyyy"/>
- </h:inputText>
- <s:selectDate for="dob" startYear="1910" endYear="2007">
- <img src="img/datepicker.png"/>
- </s:selectDate>
- <div class="validationError"><h:message for="dob"/></div>
-</div>]]></programlisting>
-
-
<para><emphasis>Example</emphasis></para>
<mediaobject>
<imageobject role="fo">
- <imagedata fileref="images/controls-selectdate.png" align="center"/>
+ <imagedata fileref="images/controls-seamtext.png" align="center" scalefit="1"/>
</imageobject>
<imageobject role="html">
- <imagedata fileref="images/controls-selectdate.png" align="center"/>
+ <imagedata fileref="images/controls-seamtext.png" align="center"/>
</imageobject>
</mediaobject>
-
- <para><emphasis>CSS Styling</emphasis></para>
+
+ </section>
+
+ </section>
+
+ <section>
+ <title>Dropdowns</title>
+
+ <section>
+ <title><literal><s:enumItem></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
<para>
- The following list describes the CSS class names that are used to control the style of the selectDate control.
+ Creates a <literal>SelectItem</literal> from an enum value.
</para>
+
+ <para><emphasis>Attributes</emphasis></para>
<itemizedlist>
- <listitem>
- <para>
- <literal>seam-date</literal> — This class is applied to the outer <literal>div</literal> containing the
- popup calendar. (1) It is also applied to the <literal>table</literal> that controls the inner layout of the
- calendar. (2)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-header</literal> — This class is applied to the calendar header table row (<literal>tr</literal>)
- and header table cells (<literal>td</literal>). (3)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-header-prevMonth</literal> — This class is applied to the "previous month" table cell,
- (<literal>td</literal>), which when clicked causes the calendar to display the month prior to the one currently
- displayed. (4)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-header-nextMonth</literal> — This class is applied to the "next month" table cell,
- (<literal>td</literal>), which when clicked causes the calendar to display the month following the one currently
- displayed. (5)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-headerDays</literal> — This class is applied to the calendar days header row
- (<literal>tr</literal>), which contains the names of the week days. (6)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-footer</literal> — This class is applied to the calendar footer row
- (<literal>tr</literal>), which displays the current date. (7)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-inMonth</literal> — This class is applied to the table cell
- (<literal>td</literal>) elements that contain a date within the month currently displayed. (8)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-outMonth</literal> — This class is applied to the table cell
- (<literal>td</literal>) elements that contain a date outside of the month currently displayed. (9)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-selected</literal> — This class is applied to the table cell
- (<literal>td</literal>) element that contains the currently selected date. (10)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-dayOff-inMonth</literal> — This class is applied to the table cell
- (<literal>td</literal>) elements that contain a "day off" date (i.e. weekend days, Saturday and Sunday)
- within the currently selected month. (11)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-dayOff-outMonth</literal> — This class is applied to the table cell
- (<literal>td</literal>) elements that contain a "day off" date (i.e. weekend days, Saturday and Sunday)
- outside of the currently selected month. (12)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-hover</literal> — This class is applied to the table cell
- (<literal>td</literal>) element over which the cursor is hovering. (13)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-monthNames</literal> — This class is applied to the <literal>div</literal>
- control that contains the popup month selector. (14)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-monthNameLink</literal> — This class is applied to the anchor (<literal>a</literal>)
- controls that contain the popup month names. (15)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-years </literal> — This class is applied to the <literal>div</literal>
- control that contains the popup year selector. (16)
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>seam-date-yearLink</literal> — This class is applied to the anchor (<literal>a</literal>)
- controls that contain the popup years. (15)
- </para>
- </listitem>
+ <listitem>
+ <para>
+ <literal>enumValue</literal> — the string
+ representation of the enum value.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>label</literal> — the label to be used when
+ rendering the <literal>SelectItem</literal>.
+ </para>
+ </listitem>
</itemizedlist>
+
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<h:selectOneRadio id="radioList"
+ layout="lineDirection"
+ value="#{newPayment.paymentFrequency}">
+ <s:convertEnum />
+ <s:enumItem enumValue="ONCE" label="Only Once" />
+ <s:enumItem enumValue="EVERY_MINUTE" label="Every Minute" />
+ <s:enumItem enumValue="HOURLY" label="Every Hour" />
+ <s:enumItem enumValue="DAILY" label="Every Day" />
+ <s:enumItem enumValue="WEEKLY" label="Every Week" />
+</h:selectOneRadio>]]></programlisting>
+ </section>
+
+ <section>
+ <title><literal><s:selectItems></literal></title>
- <mediaobject>
- <imageobject role="fo">
- <imagedata fileref="images/controls-selectdatecss.png" align="center" scalefit="1"/>
- </imageobject>
- <imageobject role="html">
- <imagedata fileref="images/controls-selectdatecss.png" align="center"/>
- </imageobject>
- </mediaobject>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
+ <para><emphasis>Description</emphasis></para>
<para>
- <literal><s:selectItems></literal>
+ Creates a <literal>List<SelectItem></literal> from a List, Set, DataModel or Array.
</para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
- <para>
- Creates a <literal>List<SelectItem></literal> from a List, Set, DataModel or Array.
- </para>
- <para><emphasis>Attributes</emphasis></para>
- <itemizedlist>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
<listitem>
- <para>
- <literal>value</literal> — an EL expression specifying the data that backs the <literal>List<SelectItem></literal>
- </para>
+ <para>
+ <literal>value</literal> — an EL expression
+ specifying the data that backs the
+ <literal>List<SelectItem></literal>
+ </para>
</listitem>
- <listitem>
- <para>
- <literal>var</literal> — defines the name of the local variable that holds the current object during iteration
- </para>
+ <listitem>
+ <para>
+ <literal>var</literal>— defines the name of the local
+ variable that holds the current object during iteration
+ </para>
</listitem>
<listitem>
- <para>
- <literal>label</literal> — the label to be used when rendering the <literal>SelectItem</literal>. Can reference
- the <literal>var</literal> variable
- </para>
+ <para>
+ <literal>label</literal> — the label to be used when
+ rendering the <literal>SelectItem</literal>. Can reference
+ the <literal>var</literal> variable.
+ </para>
</listitem>
<listitem>
- <para>
- <literal>itemValue</literal> — Value to return to the server if this option is selected. Optional, by default the <literal>var</literal> object is used. Can reference the <literal>var</literal> variable
- </para>
+ <para>
+ <literal>itemValue</literal> — Value to return to the
+ server if this option is selected. Optional, by default the
+ <literal>var</literal> object is used. Can reference the
+ <literal>var</literal> variable.
+ </para>
</listitem>
-
- <listitem>
- <para>
- <literal>disabled</literal> — if true the <literal>SelectItem</literal> will be rendered disabled. Can reference
- the <literal>var</literal> variable
- </para>
+
+ <listitem>
+ <para>
+ <literal>disabled</literal>
+ — if true the <literal>SelectItem</literal> will be
+ rendered disabled. Can reference the <literal>var</literal>
+ variable.
+ </para>
</listitem>
<listitem>
- <para>
- <literal>noSelectionLabel</literal> — specifies the (optional) label to place at the top of list (if
- <literal>required="true"</literal> is also specified then selecting this value will cause a validation error)
- </para>
+ <para>
+ <literal>noSelectionLabel</literal> — specifies the
+ (optional) label to place at the top of list (if
+ <literal>required="true"</literal> is also specified then
+ selecting this value will cause a validation error).
+ </para>
</listitem>
<listitem>
- <para>
- <literal>hideNoSelectionLabel</literal> — if true, the <literal>noSelectionLabel</literal> will be hidden
- when a value is selected
- </para>
+ <para>
+ <literal>hideNoSelectionLabel</literal> — if true,
+ the <literal>noSelectionLabel</literal> will be hidden when
+ a value is selected
+ </para>
</listitem>
- </itemizedlist>
- <para><emphasis>Usage</emphasis></para>
+ </itemizedlist>
+ <para><emphasis>Usage</emphasis></para>
<programlisting role="XHTML"><![CDATA[<h:selectOneMenu value="#{person.age}"
converter="ageConverter">
<s:selectItems value="#{ages}" var="age" label="#{age}" />
</h:selectOneMenu>]]></programlisting>
- </entry>
- </row>
+ </section>
+
+ </section>
+
+ <section>
+ <title>Other</title>
+
+ <section>
+ <title><literal><s:cache></literal></title>
- <row>
- <entry valign="top">
- <para>
- <literal><s:span></literal>
- </para>
- </entry>
- <entry valign="top">
<para><emphasis>Description</emphasis></para>
<para>
- Render a HTML <literal><span></literal>.
+ Cache the rendered page fragment using JBoss Cache. Note that
+ <literal><s:cache></literal> actually uses the instance
+ of JBoss Cache managed by the built-in
+ <literal>pojoCache</literal> component.
</para>
<para><emphasis>Attributes</emphasis></para>
- <para>
- None.
- </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>key</literal> — the key to cache rendered
+ content, often a value expression. For example, if we were
+ caching a page fragment that displays a document, we might
+ use <literal>key="Document-#{document.id}"</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>enabled</literal> — a value expression that
+ determines if the cache should be used.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>region</literal> — a JBoss Cache node to use
+ (different nodes can have different expiry policies).
+ </para>
+ </listitem>
+ </itemizedlist>
+
<para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:span styleClass="required" rendered="#{required}">*</s:span>]]></programlisting>
- </entry>
- </row>
+ <programlisting role="XHTML"><![CDATA[<s:cache key="entry-#{blogEntry.id}" region="pageFragments">
+ <div class="blogEntry">
+ <h3>#{blogEntry.title}</h3>
+ <div>
+ <s:formattedText value="#{blogEntry.body}"/>
+ </div>
+ <p>
+ [Posted on 
+ <h:outputText value="#{blogEntry.date}">
+ <f:convertDateTime timezone="#{blog.timeZone}" locale="#{blog.locale}"
+ type="both"/>
+ </h:outputText>]
+ </p>
+ </div>
+</s:cache>]]></programlisting>
+
+ </section>
- <row>
- <entry valign="top">
- <para>
- <literal><s:taskId></literal>
- </para>
- </entry>
- <entry valign="top">
+ <section>
+ <title><literal><s:fileUpload></literal></title>
+
<para><emphasis>Description</emphasis></para>
- <para>
- Add the task id to an output link (or similar JSF control), when the
- task is available via <literal>#{task}</literal>.
- </para>
- <para><emphasis>Attributes</emphasis></para>
<para>
- None.
+ Renders a file upload control. This control must be used within
+ a form with an encoding type of
+ <literal>multipart/form-data</literal>, i.e:
</para>
- </entry>
- </row>
- <row>
- <entry valign="top">
+ <programlisting role="XHTML"><![CDATA[<h:form enctype="multipart/form-data">]]></programlisting>
+
<para>
- <literal><s:validate></literal>
+ For multipart requests, the Seam Multipart servlet filter must
+ also be configured in <literal>web.xml</literal>:
</para>
- </entry>
- <entry valign="top">
- <para><emphasis>Description</emphasis></para>
+
+ <programlisting role="XML"><![CDATA[<filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+</filter>
+
+<filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+</filter-mapping>]]></programlisting>
+
+ <para><emphasis>Configuration</emphasis></para>
+
<para>
- A non-visual control, validates a JSF input field against the bound
- property using Hibernate Validator.
+ The following configuration options for multipart requests may be
+ configured in components.xml:
</para>
- <para><emphasis>Attributes</emphasis></para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>createTempFiles</literal> — if this option
+ is set to true, uploaded files are streamed to a temporary
+ file instead of in memory.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>maxRequestSize</literal> — the maximum size
+ of a file upload request, in bytes.
+ </para>
+ </listitem>
+ </itemizedlist>
+
<para>
- None.
+ Here's an example:
</para>
+
+ <programlisting role="XML"><![CDATA[<component class="org.jboss.seam.web.MultipartFilter">
+ <property name="createTempFiles">true</property>
+ <property name="maxRequestSize">1000000</property>
+</component>]]></programlisting>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>data</literal> — this value binding receives
+ the binary file data. The receiving field should be
+ declared as a <literal>byte[]</literal> or
+ <literal>InputStream</literal> (required).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>contentType</literal> — this value binding
+ receives the file's content type (optional).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fileName</literal> — this value binding
+ receives the filename (optional).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fileSize</literal> — this value binding
+ receives the file size (optional).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>accept</literal> — a comma-separated list of
+ content types to accept, may not be supported by the
+ browser. E.g. <literal>"images/png,images/jpg"</literal>,
+ <literal>"images/*"</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>style</literal> — The control's style
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>styleClass</literal> — The control's style
+ class
+ </para>
+ </listitem>
+ </itemizedlist>
<para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<h:inputText id="userName" required="true"
- value="#{customer.userName}">
- <s:validate />
-</h:inputText>
-<h:message for="userName" styleClass="error" />]]></programlisting>
- </entry>
- </row>
+ <programlisting role="XHTML"><![CDATA[<s:fileUpload id="picture" data="#{register.picture}"
+ accept="image/png"
+ contentType="#{register.pictureContentType}" />]]></programlisting>
+
+ </section>
- <row>
- <entry valign="top">
- <para><literal><s:validateAll></literal></para>
- </entry>
- <entry valign="top">
+ <section>
+ <title><literal><s:graphicImage></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- A non-visual control, validates all child JSF input fields against their bound
- properties using Hibernate Validator.
+ An extended <literal><h:graphicImage></literal> that allows
+ the image to be created in a Seam Component; further transforms
+ can be applied to the image.
</para>
+ <para>
+ All attributes for <literal><h:graphicImage></literal> are
+ supported, as well as:
+ </para>
+
<para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>value</literal> — image to display. Can be
+ a path <literal>String</literal> (loaded from the
+ classpath), a <literal>byte[]</literal>, a
+ <literal>java.io.File</literal>, a
+ <literal>java.io.InputStream</literal> or a
+ <literal>java.net.URL</literal>. Currently supported image
+ formats are <literal>image/png</literal>,
+ <literal>image/jpeg</literal> and
+ <literal>image/gif</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fileName</literal> — if not specified the
+ served image will have a generated file name. If you want
+ to name your file, you should specify it here. This name
+ should be unique
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Transformations</emphasis></para>
<para>
- None.
+ To apply a transform to the image, you would nest a tag
+ specifying the transform to apply. Seam currently supports these
+ transforms:
</para>
- <para><emphasis>Usage</emphasis></para>
- <programlisting role="XHTML"><![CDATA[<s:validateAll>
- <div class="entry">
- <h:outputLabel for="username">Username:</h:outputLabel>
- <h:inputText id="username" value="#{user.username}"
- required="true"/>
- <h:message for="username" styleClass="error" />
- </div>
- <div class="entry">
- <h:outputLabel for="password">Password:</h:outputLabel>
- <h:inputSecret id="password" value="#{user.password}"
- required="true"/>
- <h:message for="password" styleClass="error" />
- </div>
- <div class="entry">
- <h:outputLabel for="verify">Verify Password:</h:outputLabel>
- <h:inputSecret id="verify" value="#{register.verify}"
- required="true"/>
- <h:message for="verify" styleClass="error" />
- </div>
-</s:validateAll>]]></programlisting>
- </entry>
- </row>
-
- <row>
- <entry valign="top">
+ <variablelist>
+ <varlistentry>
+ <term>
+ <literal><s:transformImageSize></literal>
+ </term>
+ <listitem>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>width</literal> — new width of the
+ image
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>height</literal> — new height of the
+ image
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>maintainRatio</literal> — if
+ <literal>true</literal>, and
+ <emphasis>one</emphasis> of
+ <literal>width</literal>/<literal>height</literal>
+ are specified, the image will be resized with the
+ dimension not specified being calculated to
+ maintain the aspect ratio.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>factor</literal> — scale the image
+ by the given factor
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <literal><s:transformImageBlur></literal>
+ </term>
+ <listitem>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>radius</literal> — perform a
+ convolution blur with the given radius
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <literal><s:transformImageType></literal>
+ </term>
+ <listitem>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>contentType</literal> — alter the
+ type of the image to either
+ <literal>image/jpeg</literal> or
+ <literal>image/png</literal>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
<para>
- <literal><s:validateFormattedText></literal>
+ It's easy to create your own transform - create a
+ <literal>UIComponent</literal> which implements
+ <literal>org.jboss.seam.ui.graphicImage.ImageTransform</literal>.
+ Inside the <literal>applyTransform()</literal>method use
+ <literal>image.getBufferedImage()</literal> to get the original
+ image and <literal>image.setBufferedImage()</literal> to set your
+ transformed image. Transforms are applied in the order specified
+ in the view.
</para>
- </entry>
- <entry valign="top">
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:graphicImage rendered="#{auction.image ne null}"
+ value="#{auction.image.data}">
+ <s:transformImageSize width="200" maintainRatio="true"/>
+</s:graphicImage>]]></programlisting>
+ </section>
+
+ <section>
+ <title><literal><s:remote></literal></title>
+
<para><emphasis>Description</emphasis></para>
<para>
- Checks that the submitted value is valid Seam Text
+ Generates the Javascript stubs required to use Seam Remoting.
</para>
+
<para><emphasis>Attributes</emphasis></para>
- <para>
- None.
- </para>
- </entry>
- </row>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>include</literal> — a comma-separated list
+ of the component names (or fully qualified class names)for
+ which to generate Seam Remoting Javascript stubs. See
+ <xref linkend="remoting"/> for more details.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Usage</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:remote include="customerAction,accountAction,com.acme.MyBean"/>]]></programlisting>
+ </section>
+ </section>
+ </section>
- </tbody>
- </tgroup>
- </table>
-</section>
-<section id="controls.annotations">
- <title>Annotations</title>
-
- <para>
- Seam also provides annotations to allow you to use Seam components as JSF
- converters and validators:
-
- </para>
- <variablelist spacing="compact">
- <varlistentry>
- <term>
- <literal>@Converter</literal>
- </term>
- <listitem>
- <programlisting role="JAVA"><![CDATA[@Name("itemConverter")
-@BypassInterceptors
-@Converter
-public class ItemConverter implements Converter {
-
- @Transactional
- public Object getAsObject(FacesContext context, UIComponent cmp, String value) {
- EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");
- entityManager.joinTransaction();
- // Do the conversion
- }
-
- public String getAsString(FacesContext context, UIComponent cmp, Object value) {
- // Do the conversion
- }
-
-}]]></programlisting>
- <programlisting role="XHTML"><![CDATA[<h:inputText value="#{shop.item}" converter="itemConverter" />]]></programlisting>
-
- <para>
- Registers the Seam component as a JSF converter. Shown here is a
- converter which is able to access the JPA EntityManager inside a
- JTA transaction, when converting the value back to it's object
- representation.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <literal>@Validator</literal>
- </term>
- <listitem>
- <programlisting role="JAVA"><![CDATA[@Name("itemValidator")
-@BypassInterceptors
-@Validator
-public class ItemValidator implements Validator {
+ <section id="controls.annotations">
+ <title>Annotations</title>
+
+ <para>
+ Seam also provides annotations to allow you to use Seam components as JSF
+ converters and validators:
+
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <literal>@Converter</literal>
+ </term>
+ <listitem>
+ <programlisting role="JAVA"><![CDATA[@Name("itemConverter")
+ @BypassInterceptors
+ @Converter
+ public class ItemConverter implements Converter {
+
+ @Transactional
+ public Object getAsObject(FacesContext context, UIComponent cmp, String value) {
+ EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");
+ entityManager.joinTransaction();
+ // Do the conversion
+ }
+
+ public String getAsString(FacesContext context, UIComponent cmp, Object value) {
+ // Do the conversion
+ }
+
+ }]]></programlisting>
- public void validate(FacesContext context, UIComponent cmp, Object value)
- throws ValidatorException {
- ItemController ItemController = (ItemController) Component.getInstance("itemController");
- return itemController.validate(value);
- }
-
- }]]></programlisting>
-
- <programlisting role="XHTML"><![CDATA[<h:inputText value="#{shop.item}" validator="itemValidator" />]]></programlisting>
- <para>
- Registers the Seam component as a JSF validator. Shown here is a
- validator which injects another Seam component; the injected
- component is used to validate the value.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
-</section>
+ <programlisting role="XHTML"><![CDATA[<h:inputText value="#{shop.item}" converter="itemConverter" />]]></programlisting>
+
+ <para>
+ Registers the Seam component as a JSF converter. Shown here is a
+ converter which is able to access the JPA EntityManager inside a
+ JTA transaction, when converting the value back to it's object
+ representation.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <literal>@Validator</literal>
+ </term>
+ <listitem>
+ <programlisting role="JAVA"><![CDATA[@Name("itemValidator")
+ @BypassInterceptors
+ @Validator
+ public class ItemValidator implements Validator {
+
+ public void validate(FacesContext context, UIComponent cmp, Object value)
+ throws ValidatorException {
+ ItemController ItemController = (ItemController) Component.getInstance("itemController");
+ return itemController.validate(value);
+ }
+
+ }]]></programlisting>
+
+ <programlisting role="XHTML"><![CDATA[<h:inputText value="#{shop.item}" validator="itemValidator" />]]></programlisting>
+ <para>
+ Registers the Seam component as a JSF validator. Shown here is a
+ validator which injects another Seam component; the injected
+ component is used to validate the value.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
</chapter>
16 years, 7 months