[JBoss Seam] - Need an advice to improve Seam-ICEfaces fileUpload Session b
by gus888
Hi all,
I reviewed the Seam-ICEfaces fileUpload demo codes (as follows), and I want to change the SFSB to conversation bean. In addition, the codes seem a little hard to follow, anybody can give some advice on how to simplify them? I really appreciate it. Thank you very much in advance. The demo codes are listed as follows:
| /**
| * <p>The InputFileBackerBean class is the backing bean for the inputfile showcase
| * demonstration. It is used to store the state of the file uploading
| * operation.</p>
| *
| * @since 0.3.0
| */
| @Stateful
|
| @Name("inputFileBackerBean")
| @Scope(ScopeType.SESSION)
| public class InputFileBackerBean implements InputFileBacker, Renderable, Serializable {
|
| private int percent = -1;
| private File file = null;
| private transient PersistentFacesState state;
|
| private String fileName = "";
| private String contentType = "";
|
| private InnerProgressMonitor pmImpl;
|
| private static Log log =
| LogFactory.getLog(InputFileBackerBean.class);
|
| public InputFileBackerBean() {
| pmImpl = new InnerProgressMonitor();
| state = PersistentFacesState.getInstance();
| }
|
| public PersistentFacesState getState() {
| return state;
| }
|
| public void renderingException (RenderingException re) {
| log.error("Rendering exception " , re);
| }
|
|
| public void setPercent(int percent) {
| this.percent = percent;
| }
|
| public int getPercent() {
| return percent;
| }
|
| public void setFile(File file) {
| this.file = file;
| }
|
| public File getFile() {
| return file;
| }
|
| public InnerProgressMonitor getProgressMonitor() {
| return pmImpl;
| }
|
| public InnerProgressMonitor getActionMonitor() {
| return pmImpl;
| }
|
|
| public void setFileName(String fileName) {
| this.fileName = fileName;
| }
|
| public String getFileName() {
|
| return fileName;
| }
|
| public void setContentType(String contentType) {
| this.contentType = contentType;
| }
|
| public String getContentType() {
| return contentType;
| }
|
| @Remove
| @Destroy
| public void destroy() {
| }
|
|
| /**
| * Inner class to handle updates and action. Do this to keep the
| * render call from triggering concurrent access problems in the Bean.
| */
| public class InnerProgressMonitor implements
| Serializable {
|
|
|
| public void progress(EventObject event) {
|
| com.icesoft.faces.component.inputfile.InputFile file =
| (com.icesoft.faces.component.inputfile.InputFile) event.getSource();
| int percent = file.getFileInfo().getPercent();
| InputFileBackerBean.this.setPercent( percent );
| InputFileBackerBean.this.setFile( file.getFile() );
|
| if (log.isDebugEnabled()) {
| log.debug("Progress - Percent: " + percent);
| }
| try {
| // execute the lifecycle to initialize Seam to prevent
| // IllegalStateExceptions, and render.
| state.execute();
| state.render();
|
| } catch (RenderingException re ) {
| System.out.println("Rendering exception : " + re);
| re.printStackTrace();
| }
| }
|
|
|
|
| public String action(ActionEvent event) {
|
| com.icesoft.faces.component.inputfile.InputFile inputFile = (com.icesoft.faces.component.inputfile.InputFile) event.getSource();
| if (inputFile.getStatus() == com.icesoft.faces.component.inputfile.InputFile
| .SAVED) {
| InputFileBackerBean.this.setFileName(inputFile.getFileInfo().getFileName());
| InputFileBackerBean.this.setContentType(inputFile.getFileInfo().getContentType());
| InputFileBackerBean.this.setFile(inputFile.getFile());
|
| if (log.isDebugEnabled()) {
| log.debug("File uploaded: " + inputFile.getFileInfo().getFileName());
| }
| }
|
| if (inputFile.getStatus() == com.icesoft.faces.component.inputfile.InputFile
| .INVALID) {
| inputFile.getFileInfo().getException().printStackTrace();
| }
|
| if (inputFile.getStatus() == com.icesoft.faces.component.inputfile.InputFile
| .SIZE_LIMIT_EXCEEDED) {
| inputFile.getFileInfo().getException().printStackTrace();
| }
|
| if (inputFile.getStatus() == com.icesoft.faces.component.inputfile.InputFile
| .UNKNOWN_SIZE) {
| inputFile.getFileInfo().getException().printStackTrace();
| }
| return null;
| }
| }
|
| }
| and also the jsp codes:
<ice:panelGrid
| styleClass="componentLayoutRootTable"
| columns="1">
| <ice:panelGroup styleClass="formBorderHighlight"
| style="text-align:left">
| <ice:inputFile
| progressListener="#{inputFileBackerBean.progressMonitor.progress}"
| actionListener="#{inputFileBackerBean.actionMonitor.action}"/>
| <ice:outputProgress id="pro"
| value="#{inputFileBackerBean.percent}"/>
| <ice:outputText
| value="File Name: #{inputFileBackerBean.fileName}"/>
| <br/>
| <ice:outputText
| value="Content Type: #{inputFileBackerBean.contentType}"/>
| <ice:messages/>
| </ice:panelGroup>
| </ice:panelGrid>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049516#4049516
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049516
18 years, 10 months
[Beginners Corner] - HTTP Status 403 - Configuration error: Cannot perform access
by oei17
Hi all,
Just started with JBoss Userguide, as i follow closely up to chapter 2 Security Service and i modified all the required file as follows
jboss-web
-----------
<jboss-web>
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
web.xml
---------
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
<!-- <security-constraint>
<web-resource-collection>
<web-resource-name>Public</web-resource-name>
<url-pattern>/public/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint> -->
<security-role>
<role-name>JBossAdmin</role-name>
</security-role>
login-config.xml
------------------
<application-policy name = "jmx-console">
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">props/jmx-console-users.properties</module-option>
<module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
</login-module>
</application-policy>
jmx-console-users.properties
----------------------------------
testuser=admin2
jmx-console-roles.properties
---------------------------------
testuser=JBossAdmin
But i still getting the error shown above.
Please help... Thanks in advance.
Regards,
Nick
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049514#4049514
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049514
18 years, 10 months
[Clustering/JBoss] - topic not bound in HAJMS
by anaholzbach
Hi,
We're using JBoss 4.2.0.GA. We have two nodes running a flex-based application that calls some business methods on clustered ejbs, which in turn use JMS to update state on the client. I've setup a named partition (LCSTest) with two nodes, and gave this partition its own multicast address (there are other partitions in the network). The JMS topics are deployed in deploy-hasingleton in both nodes and the nodes are configured to access the same SQL Server datasource for JMS data.
The beans are annotated as follows:
@Stateless
| @TransactionManagement
| @Local(BedManagementService.class)
| @Remote(BedManagementService.class)
| public class BedManagementServiceBean implements BedManagementService {
|
| @Resource
| private SessionContext mSessionContext;
|
| @Resource(mappedName = "TopicConnectionFactory")
| private ConnectionFactory mJmsConnectionFactory;
|
| @Resource(mappedName = "topic/RoomService/BedStaffUpdate")
| private Topic mStaffUpdateTopic;
| ...
|
| }
and jboss.xml has these contents:
<jboss>
| <enterprise-beans>
| ...
| <session>
| <ejb-name>BedManagementServiceBean</ejb-name>
| <resource-ref>
| <res-ref-name>TopicConnectionFactory</res-ref-name>
| <jndi-name>jnp://${jboss.bind.address:localhost}:1100/TopicConnectionFactory</jndi-name>
| </resource-ref>
| <resource-ref>
| <res-ref-name>topic/RoomService/StaffUpdate</res-ref-name>
| <jndi-name>
| jnp://${jboss.bind.address:localhost}:1100/topic/RoomService/BedStaffUpdate</jndi-name>
| </resource-ref>
| <clustered>True</clustered>
| <cluster-config>
| <partition-name>
| ${jboss.partition.name:DefaultPartition}</partition-name>
| <bean-load-balance-policy>
| org.jboss.ha.framework.interfaces.RoundRobin</bean-load-balance-policy>
| </cluster-config>
| </session>
| </enterprise-beans>
|
| </jboss>
I've deployed the hajms-examples.jar in a third server to test the two nodes in the cluster, and successfully verified that the setup was working.
JNDIView lists all the beans in both nodes, but lists the topics only in the singleton master, which makes sense. But the topics are only available in the singleton master. The node that is not the master gets an NameNotFoundException "topic not bound".
Any suggestions will be much appreciated. Thanks !
Ana
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049508#4049508
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049508
18 years, 10 months