Hello, her is my solution tot he problem above, solved with JBoss Seam and Facelets 1.) First I follow the discription http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossSeamGettingStartedGuide and installed JBoss IDE and SEAM as described.
2.) Now the steps in Eclipse for an new ?Enterprise Application Project? Project Name: statelessSb J2EE Modules -> New Module: statelessSbEJB, statelessSbWeb The Workspace is defined as V:\seam-workspace Under Win CMD type as follow: (the same like 1.) V:\seam-workspace\jboss-seam-1.0.1.GA\seam-gen>seam new-wtp-project statelessSb V:\seam-workspace\jboss-seam-1.0.1.GA\seam-gen>seam new-stateless-action statelessSb StatelessCalculator V:\seam-workspace\jboss-seam-1.0.1.GA\seam-gen>seam new-action-page statelessSb home StatelessCalculator Now Refresh statelssSb, statelessSbEJB and statelessWeb in Eclipse and set ?Configure Buildpath? from statelessSbEJB (also see in 1.) Code for home.xhtml: | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | <html xmlns="http://www.w3.org/1999/xhtml" | xmlns:s="http://jboss.com/products/seam/taglib" | xmlns:ui="http://java.sun.com/jsf/facelets" | xmlns:f="http://java.sun.com/jsf" | xmlns:h="http://java.sun.com/jsf/html"> | <body> | <ui:composition template="/WEB-INF/layout/template.xhtml"> | | <ui:define name="body"> | <h1>Seam Generated Page named: "Calculator"</h1> | <h:form> | <div> | <fieldset> | <div> | <div><h:outputLabel for="start">Start age: </h:outputLabel></div> | <div><h:inputText value="#{StatelessCalculator.start}"/><br /></div> | </div> | <div> | <div><h:outputLabel>End age: </h:outputLabel></div> | <div><h:inputText value="#{StatelessCalculator.end}"/><br /></div> | </div> | <div> | <div><h:outputLabel>Growth Rate: </h:outputLabel></div> | <div><h:inputText value="#{StatelessCalculator.growthrate}"/><br /></div> | </div> | <div> | <div><h:outputLabel>saving: </h:outputLabel></div> | <div><h:inputText value="#{StatelessCalculator.saving}"/><br /></div> | </div> | <div> | <div><h:commandButton type="submit" value="Calculate" action="#{StatelessCalculator.calculate}"/></div> | </div> | <div> | <div><h:outputText>Result: "#{StatelessCalculator.resultString}"</h:outputText></div> | </div> | | </fieldset> | </div> | </h:form> | </ui:define> | | </ui:composition> | </body> | </html> | Code for StatelessCalculator.java: | package org.jboss.business; | | import javax.ejb.Local; | | @Local | public interface StatelessCalculator { | | //seam-gen method | public String doAction(); | | //add additional interface methods here | public String calculate (); | | public double calculate(int start, int end, double growth, double saving); | | public int getEnd(); | | public void setEnd(int end); | | public double getGrowthrate(); | | public void setGrowthrate(double growthrate); | | public double getSaving(); | | public void setSaving(double saving); | | public int getStart(); | | public void setStart(int start); | | public double getResult(); | | public void setResult(double result); | | public String getResultString(); | | public void setResultString(String resultString); | } | Code for StatelessCalculatorAction.java: | package org.jboss.business; | | import static org.jboss.seam.ScopeType.SESSION; | | import java.io.Serializable; | import java.text.NumberFormat; | | import javax.ejb.Stateless; | import org.jboss.seam.annotations.Name; | import org.jboss.seam.annotations.Scope; | | @Stateless | @Name("StatelessCalculator") | @Scope(SESSION) | public class StatelessCalculatorAction implements StatelessCalculator, | Serializable { | | private int start = 25; | private int end = 65; | private double growthrate = 0.08; | private double saving = 300.0; | private double result = 0; | private String resultString = null; | /** | * | */ | private static final long serialVersionUID = 1L; | | // seam-gen method | public String doAction() { | return "success"; | } | | // add additional action methods | public double calculate(int start, int end, double growth, double saving){ | double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1); | return saving * 12. * (tmp - 1) / growth; | } | | public String calculate() { | NumberFormat nf = NumberFormat.getInstance(); | nf.setMaximumFractionDigits(2); | result = calculate(start, end, growthrate, saving); | resultString = nf.format(result); | return "success"; | } | | | | public int getEnd() { | return end; | } | | public void setEnd(int end) { | this.end = end; | } | | public double getGrowthrate() { | return growthrate; | } | | public void setGrowthrate(double growthrate) { | this.growthrate = growthrate; | } | | public double getSaving() { | return saving; | } | | public void setSaving(double saving) { | this.saving = saving; | } | | public int getStart() { | return start; | } | | public void setStart(int start) { | this.start = start; | } | | public double getResult() { | return result; | } | | public void setResult(double result) { | this.result = result; | } | | public String getResultString() { | return resultString; | } | | public void setResultString(String resultString) { | this.resultString = resultString; | } | | } | Finally ADD the Project to JBoss Server, start and see the result by typing http://localhost:8080/statelessSb in browser Have fun Andreas View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970928#3970928 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970928 _______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
