Log In | Sign Up   View a printable version of the current page.
  Dashboard > flexive > ... > The security enabled announcement submission application > Announcement editing

Added by Hans Bacher, last edited by Gerhard Glos on Nov 13, 2008  (view change)
Labels: 
(None)

Announcement editing

<h:form>
    <fx:content pk="#{asubmissionBean.instancePk}" var="entry"> <!-- (1) -->
        <fx:value property="caption"/><br/>
        <fx:value property="announcementText"/><br/>
        <fx:value property="publishDate"/><br/>
        <fx:value property="publishURL"/><br/>
        <h:commandButton action="#{asubmissionBean.saveReadAll}" value='Save with "Read all" ACL'> <!-- (2) -->
            <f:setPropertyActionListener target="#{asubmissionBean.content}" value="#{entry_content}"/> <!-- (3) -->
        </h:commandButton>
        <br/>
        <h:commandButton action="#{asubmissionBean.saveEditorsOnly}" value='Save with "Editors only" ACL'> <!-- (4) -->
            <f:setPropertyActionListener target="#{asubmissionBean.content}" value="#{entry_content}"/> <!-- (3) -->
        </h:commandButton>
    </fx:content>
</h:form>

(1) <fx:content/> from the [fleXive] component library is used to create a new announcement content instance. If a FxPK primary key object is specified, the content instance identified by this primary key is loaded for editing.
(2) The Save with "Read all" ACL command button's action is bound to the saveReadAll() method of the JSF managed ASubmissionBean, which sets an instance ACL that grants all users the permission to read this content instance.
(3) The property action listener maps the in instance created by <fx:content/> to the variable content in ASubmissionBean, so that the save methods have access to the newly created content.
(4) The Save with "Editors Only" ACL command button's action is bound to the saveEditorsOnly() method of the JSF managed ASubmissionBean, which sets an instance ACL that only grants editors the permission to read this content instance.

JSF managed ASubmissionBean

ASubmissionBean's method save methods
public String saveReadAll() {
    try {
        content.setAclId(CacheAdmin.getEnvironment().getACL("Announcement Instance Read All").getId()); // (1)
        EJBLookup.getContentEngine().save(content.copy()); //(2)
    } catch (FxApplicationException e) {
        new FxFacesMsgErr(e).addToContext();
        return null;
    }
    return "instance_created";
}

public String saveEditorsOnly() {
    try {
        content.setAclId(CacheAdmin.getEnvironment().getACL("Announcement Instance Editors Only").getId()); //(3)
        EJBLookup.getContentEngine().save(content.copy());
    } catch (FxApplicationException e) {
        new FxFacesMsgErr(e).addToContext();
        return null;
    }
    return "instance_created";
}
Site running on a free Atlassian Confluence Open Source Project License granted to [fleXive] . Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.1 Build:#916 Nov 09, 2007) - Bug/feature request - Contact Administrators