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
public String saveReadAll() {
try {
content.setAclId(CacheAdmin.getEnvironment().getACL("Announcement Instance Read All").getId()); EJBLookup.getContentEngine().save(content.copy()); } 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()); EJBLookup.getContentEngine().save(content.copy());
} catch (FxApplicationException e) {
new FxFacesMsgErr(e).addToContext();
return null;
}
return "instance_created";
}