|
Hi Aaron, I guess now I get a better picture of your application structure. The generated pagecode.CustIndex.java should simply have a bunch of convenience methods. I don't believe they are required. By default, you can use this class to contain all of the property bindings. I think tool would even add it to faces-config.xml. But since you already have your Customer.java class, you might as well use it as a your backing bean. To simplify things, I would put listeners into Customer.java (the backing bean for your components). This way, listener can access all JSF component values directly. You can certainly put your Customer.java into the session (actually, JSF already puts it into the session for you, since you session-scoped your bean in the faces-config.xml). And surely you can access Customer from a separate bean, like Events.java that would contain your ActionListeners by simply calling Customer myCustomer = (Customer )session.getAttribute("customer"); I guess this is just a matter of a personal preference. Regards, Vadim. "Bartell, Aaron L. (TC)" <ALBartell@taylor To corp.com> "Websphere Development Studio Sent by: Client for iSeries" wdsci-l-bounces+b <wdsci-l@xxxxxxxxxxxx> erestet=ca.ibm.co cc m@xxxxxxxxxxxx Subject RE: [WDSCI-L] JSF Model objects - 10/29/2004 09:20 how do you fill them from AM alistener? Please respond to Websphere Development Studio Client for iSeries Thanks for the reply. Status: head is bandaged and ready to take another shot today :-) Just a couple questions to make sure I am understanding you completely. My screen file is CustIndex.jsp which auto generated pagecode.CustIndex.java. Customer.java is a bean I built from scratch. Are you recommending I put my listener (currently in Events.java) into pagecode.CustIndex.java or Customer.java? I ask because I didn't tell you about the auto-generated pagecode.CustIndex.java. (BTW, are all those protected methods in pagecode.CustIndex.java that are auto generated even used? Or rather, what is their purpose? I put System.out.println's in each of them, but none of them get called.) >By the way, looks like there should be another faces-config.xml entry for the Events.java, right? You are correct. I should have included that one also so you could get the full picture. >Anyway, this is how I would design my JSF apps, at least to get things going. Cool. I will start out in this manner. Does that mean there isn't a way to get at my model objects from a separate object that processes actions? Is that where session objects come into play in some shape or form. Thanks for all your help Vadim, it is much appreciated. Aaron Bartell -----Original Message----- From: wdsci-l-bounces@xxxxxxxxxxxx [mailto:wdsci-l-bounces@xxxxxxxxxxxx] Sent: Thursday, October 28, 2004 5:01 PM To: Websphere Development Studio Client for iSeries Subject: Re: [WDSCI-L] JSF Model objects - how do you fill them from alistener? Hi Aaron, I guess there are various ways to design your JSF applications. One of the simplest options is to put your ActionListener code into the same class that backs up your JSF components, that is Customer.java. By the way, looks like there should be another faces-config.xml entry for the Events.java, right? In any event, you might want to create your business object as a separate Java class and have Customer.java reference it. Then ActionListener will simply retrieve values of each component (name, address, etc) since they are accessible and update your business object with those values. Anyway, this is how I would design my JSF apps, at least to get things going. Hope this helps, Vadim. Internet: berestet@xxxxxxxxxx "Bartell, Aaron L. (TC)" <ALBartell@taylor To corp.com> "Websphere Development Studio Sent by: Client for iSeries" wdsci-l-bounces@m <wdsci-l@xxxxxxxxxxxx> idrange.com cc Subject 10/28/2004 04:42 [WDSCI-L] JSF Model objects - how PM do you fill them from a listener? Please respond to Websphere Development Studio Client for iSeries Status: Head bleeding from wall hitting Ok, I have just about the simplest JSF app I can think of and what just isn't making sense to me is how I update my "model" or "business logic" object from an action listener that isn't part of the model object. I am displaying an input text field where the user will enter a number. When they hit the submit button an actionListener will get called (this works). But how do I fill in my Customer java object from the action listener method? The Customer object is registered in the faces-config.xml as follows: <managed-bean> <managed-bean-name>customer</managed-bean-name> <managed-bean-class>com.wgeb.customer.Customer</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> As you can see below I am filling in the outputFormat fields with #{customer.xxxxx} which should map to the Customer object and pull values from it. CustIndex.jsp: ... <f:view> <BODY> <hx:scriptCollector id="scriptCollector1"> <h:form styleClass="form" id="form1"> <P><h:outputText styleClass="outputText" id="text1" value="Enter Customer"></h:outputText><h:inputText styleClass="inputText" id="text2"></h:inputText><hx:commandExButton type="submit" value="Display Customer" styleClass="commandExButton" id="button1" actionListener="#{listener.displayCustomer}"> </hx:commandExButton><BR> <BR> <BR> <h:outputText styleClass="outputText" id="text3" value="Name"></h:outputText> <h:outputFormat styleClass="outputFormat" id="format1" value="#{customer.name}"> </h:outputFormat><BR> <h:outputText styleClass="outputText" id="text4" value="Address"></h:outputText> <h:outputFormat styleClass="outputFormat" id="format2" value="#{customer.address}"></h:outputFormat><BR> <h:outputText styleClass="outputText" id="text5" value="City"></h:outputText> <h:outputFormat styleClass="outputFormat" id="format3" value="#{customer.city}"></h:outputFormat><BR> <h:outputText styleClass="outputText" id="text6" value="State"></h:outputText><h:outputFormat styleClass="outputFormat" id="format4" value="#{customer.state}"></h:outputFormat> <BR> <h:outputText styleClass="outputText" id="text7" value="Zip"></h:outputText><h:outputFormat styleClass="outputFormat" id="format5" value="#{customer.zip}"></h:outputFormat> <BR> <BR> </P> </h:form> </hx:scriptCollector> </BODY> </f:view> ... Customer.java: package com.wgeb.customer; public class Customer { public Customer() { } private String name = ""; private String address = ""; private String city = ""; private String state = ""; private String zip = ""; public String getAddress() { return address; } public String getCity() { return city; } public String getName() { return name; } public String getState() { return state; } public String getZip() { return zip; } public void setAddress(String string) { address = string; } public void setCity(String string) { city = string; } public void setName(String string) { name = string; } public void setState(String string) { state = string; } public void setZip(String string) { zip = string; } } Events.java: package listeners; import javax.faces.event.AbortProcessingException; import javax.faces.event.ActionEvent; import javax.faces.event.ActionListener; public class Events implements ActionListener { public Events() { } public void processAction(ActionEvent arg0) throws AbortProcessingException { } public void displayCustomer(ActionEvent arg0) throws AbortProcessingException { //!!!! Here is where I want to fill in the customer object !!!!!!!!! // Eventually this will be calling some RPG programs to get the customer information } } _______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l. _______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l. _______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.