[ajug-members] seam help

mike barnes mdb3624 at gmail.com
Mon May 16 15:09:18 EDT 2011


I am trying to get an object from a collection passed to a modal window and
am having no luck figuring out how to do this. I am able to create a table
of objects but am unable to pass a selected object to the modal window. This
modal window shows no data.

=============================================== Java Bean
==========================
package com.weenergies.cs.ebpp.action;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.log.Log;

import com.weenergies.cs.interactive_bill.utils.CsServiceInjector;
import com.weenergies.cs.model.Account;
import com.weenergies.cs.model.Address;
import com.weenergies.cs.model.Bill;
import com.weenergies.cs.model.BillSummary;
import com.weenergies.cs.model.Customer;
import
com.weenergies.cs.services.generated.cis_bill_service_account.BillingService;
import com.weenergies.cs.services.generated.cis_service_myaccount.BillData;
import
com.weenergies.cs.services.generated.cis_service_myaccount.CommonInput;
import
com.weenergies.cs.services.generated.cis_service_myaccount.GetAccountListInput;
import
com.weenergies.cs.services.generated.cis_service_myaccount.GetAccountListOutput;
import
com.weenergies.cs.services.generated.cis_service_myaccount.GetBillListInput;
import
com.weenergies.cs.services.generated.cis_service_myaccount.MyAccountData;
import
com.weenergies.cs.services.generated.cis_service_myaccount.MyAccountService;

@Name("bHomeView")
@Scope(ScopeType.SESSION)
public class BHomeView {
    @Logger
    private Log log;

    @In
    StatusMessages statusMessages;

    @In(required = false)
    @Out(required = false)
    String accountNumber;

    @In(value = CsServiceInjector.MY_ACCOUNT_SERVICE, required = true)
    MyAccountService myAccountSrv;
    @In(value = CsServiceInjector.BILLING_SERVICE, required = true)
    BillingService billSrv;

    public List<String> accounts;

    @Out(required = false)
    public List<javax.faces.model.SelectItem> selAccounts;

    @In(required = false)
    public String customerId;

    @In(required = false)
    public String energyAccountId;

    @DataModel
    private List<BillSummary> billSummaries;

    @DataModelSelection
    private BillSummary billSummary;

    public void bHomeView() {
        // implement your business logic here
        log.info("bHomeView.bHomeView() action called");
        statusMessages.add("bHomeView");
    }

    @Factory("billSummaries")
    public void getBillList() throws Exception {
        accounts = new ArrayList<String>();
        selAccounts = new ArrayList<javax.faces.model.SelectItem>();
        CommonInput commonInput = new CommonInput();
        GetAccountListInput dataInput = new GetAccountListInput();
        GetAccountListOutput output;
        // GetAccountListOutput accountListOut;

        commonInput.setLoginId("soapuiId");
        dataInput.setProfileId(customerId);
        // dataInput.setProfileId(customerId);
        log.debug("Custome rID == " + customerId);
        log.debug("call the WS in bill home....");
        // Call the Bill Service SOAP WS
        output = myAccountSrv.getAccountList(commonInput, dataInput);
        GetBillListInput billInput = new GetBillListInput();
        billInput.setProfileId(customerId);
        try {
            List<MyAccountData> accountList =
output.getData().getMyAccounts();
            List<BillData> billList =
                    myAccountSrv.getBillList(commonInput,
billInput).getData().getBills();
            billSummaries = new ArrayList<BillSummary>();
            for (MyAccountData myData : accountList) {
                BillData currentBillData = null;
                boolean found = false;
                for (BillData bill : billList) {
                    if
(bill.getEnergyAccountId().equals(myData.getEnergyAccountId()) && !found) {
                        currentBillData = bill;
                        found = true;
                    }
                }

                Bill currentBill = new Bill(currentBillData);
                BillSummary summary = new BillSummary();
                summary.setAccount(new Account());

summary.getAccount().setEnergyAccountId(myData.getEnergyAccountId());
                summary.getAccount().setNickname(myData.getNickname());
                summary.setCurrentBill(currentBill);
                summary.getAccount().setPaperFreeBillingFlag(
                        currentBillData.isPaperFreeBillingFlag());

summary.getAccount().setReminderEmailFlag(currentBillData.isDueDateReminderFlag());
                summary.getAccount().setCustomer(new Customer());
                summary.getAccount().getCustomer()

.setCustomerName(myData.getCustomer().getCustomerName());
                summary.getAccount().getCustomer()

.setPrimaryCustomerFlag(myData.getCustomer().isPrimaryCustomerFlag());
                summary.getAccount().setAddress(new
Address(myData.getPremiseAddress()));

                accounts.add(myData.getEnergyAccountId());
                selAccounts.add(new SelectItem(myData.getEnergyAccountId(),
                        processAccountNumber(myData.getEnergyAccountId()) +
' '
                                + summary.getAccount().getNickname()));
                accountNumber = (String)selAccounts.get(0).getValue();
                log.debug("Account Number == " + accountNumber);
                billSummaries.add(summary);
            }
            if (billSummaries.size() > 0) {
                billSummary = billSummaries.get(0);
            }
        } catch (Exception e) {
            log.debug(e);
        }
        log.debug("finshed get bill list in BHomeView");
    }

    public List<BillSummary> getBillSummaries() {
        return billSummaries;
    }

    public BillSummary getBillSummary() {
        return billSummary;
    }

    public String getCustomerId() {
        return customerId;
    }

    public String getEnergyAccountId() {
        return energyAccountId;
    }

    public void setBillSummaries(List<BillSummary> billSummaries) {
        this.billSummaries = billSummaries;
    }

    public void setBillSummary(BillSummary billSummary) {
        this.billSummary = billSummary;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public void setEnergyAccountId(String energyAccountID) {
        energyAccountId = energyAccountID;
    }

    // Fill in the empty spaces with 0's and mask with some dashes
    private String processAccountNumber(String acctNumber) {
        // String acctNumber = acctNumber.toString();
        log.debug(acctNumber);
        int initialLength = acctNumber.length();
        if (acctNumber.length() < 10) {
            for (int x = 0; x < (10 - initialLength); x++) {
                acctNumber = '0' + acctNumber;
                log.debug(acctNumber);
            }
        }
        log.debug("acctNumber == " + acctNumber);
        String begin = acctNumber.substring(0, 4);
        String middle = acctNumber.substring(4, 7);
        String end = acctNumber.substring(7, 10);

        return begin + '-' + middle + '-' + end;

    }

}

=================== Driver Page (bHomeView.xhtml)=========================
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j" template="Template.xhtml">

    <ui:define name="content">
        <h:form id="homeViewForm">
            <div id="weNavBufferSelected" class="weNavBufferSelectedClass"
                style="background: url(./images/tab_bill.png);"></div>
            <div id="weNavBuffer" class="weNavBufferClass"></div>
            <div id="AccountBox" class="weAccountInfoBoxClass">
                <h:dataTable id="accountsTable" class="weDataTable"
border="1" value = "#{billSummaries}" var="item">
                    <h:column>
                        <h:outputText
value="#{item.account.energyAccountId}"/>
                    </h:column>
                    <h:column>
                        <h:outputText
value="#{item.currentBill.amountDue}"/>
                    </h:column>
                    <h:column>
                        <div class="floatRightDiv">
                            <h:graphicImage id="payButton"
styleClass="payButtonClass"

onmouseout="this.src='images/pay-button.png'"
                                onmouseover="this.src='images/pay_h.png'"
value="Pay"

url="/images/pay-button.png"></h:graphicImage>
                            <rich:componentControl for="paypanel"
attachTo="payButton"
                                operation="show" event="onclick">
                                <f:param name="billSummary" value="#{item}"
/>
                            </rich:componentControl>
                        </div>
                    </h:column>
                </h:dataTable>
            </div>
            <ui:include src="/subviews/PaymentModal.xhtml"/>
        </h:form>
    </ui:define>
</ui:composition>

================== PaymentModal.xhtml ==================================
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j">
            <rich:modalPanel id="paypanel" width="950" height="325">
                    <f:facet name="header">
                        <h:panelGroup>
                            <h:outputText value="Pay Your Bill:
"></h:outputText>
                            <h:outputText style="font-weight:bold;
color:#03498b" value="#{billSummary.currentBill.amountDue}"/>
                        </h:panelGroup>
                    </f:facet>
                    <f:facet name="controls">
                        <h:panelGroup>
                            <h:graphicImage
value="/images/close-window-btn.png" styleClass="hidelink" id="hidelink"/>
                            <rich:componentControl for="paypanel"
attachTo="hidelink" operation="hide" event="onclick"/>
                        </h:panelGroup>
                    </f:facet>
                    <div style="overflow:auto;">
                            <div style="overflow:auto; min-height:250px;">
                                <div id="firstColumn" style="float:left;
width:30%;">
                                    <h:outputText style="font-weight:bold;
color:#03498b" value="1. When"/>&nbsp;<h:outputText value="due
mm/dd/yyyy"/><br/>
                                     <h:selectOneRadio
layout="pageDirection">
                                         <f:selectItem itemValue="1"
itemLabel="Pay Now" /><br/>
                                         <f:selectItem itemValue="2"
itemLabel="Schedule payment:" />
                                     </h:selectOneRadio>

                                </div>
                                <div id="secondColumn" style="float:left;
width:28%;"><h:outputText style="font-weight:bold; color:#03498b" value="2.
Amount"/>
                                    <h:selectOneRadio
layout="pageDirection">
                                         <f:selectItem
                                             itemValue="1"
                                             itemLabel="Pay Amount Due: ">
                                             <h:outputText
style="font-weight:bold; color:#03498b"
value="#{billSummary.currentBill.amountDue}"/>
                                         </f:selectItem>
                                         <br/>
                                         <f:selectItem itemValue="2"
itemLabel="Pay Other Amount:" />
                                     </h:selectOneRadio>
                                     <h:inputText></h:inputText>
                                </div>
                                <div id="thirdColumn" style="float:left;
width:40%;"><h:outputText style="font-weight:bold; color:#03498b" value="3.
Method"/><br/>
                                    <div style="padding-left:10px;
overflow:auto; width:100%">
                                        <h:outputText
value="Online"/><br/><br/>
                                        <h:outputText value="Payment
Accounts"/><br/>
                                        <div style="overflow:auto;
padding-bottom:10px; float:left;">
                                            <div style="float:left;">
                                                <h:selectOneRadio
layout="pageDirection">
                                                     <f:selectItem
itemValue="1" itemLabel="Chase Bank *********4432" ></f:selectItem>
                                                     <f:selectItem
itemValue="2" itemLabel="Bank of America *********1323" ></f:selectItem>
                                                 </h:selectOneRadio>
                                             </div>
                                             <div style="float:right;">
                                                     <h:outputLink
style="padding-bottom:5px;"><h:outputText value="View / Edit |
Remove"></h:outputText></h:outputLink><br/>
                                                     <h:outputLink
style="padding-bottom:5px;"><h:outputText value="View / Edit |
Remove"></h:outputText></h:outputLink>
                                             </div>
                                         </div>
                                         <br/><br/>
                                         <h:outputLink
id="addPaymentAccount" value="#"><h:outputText value="Add Payment
Account"/></h:outputLink>
                                         <rich:componentControl
for="addPaymentAccountsPanel" attachTo="addPaymentAccount" operation="show"
event="onclick"/><br/>
                                         <h:outputLink
id="payCreditCardLink" value="#"><h:outputText value="Credit
Card"/></h:outputLink><h:outputText style="color:#606060;
font-style:italic;" value="($3.95 fee)"/>
                                        <rich:componentControl
for="creditCardPaymentPanel" attachTo="payCreditCardLink" operation="show"
event="onclick"/>
                                    </div>
                                </div>
                            </div>
                         <div id="popupCommandButtons"
style="overflow:auto;">
                               <div style="float:right;">
                                <h:graphicImage id="okPayButton"
onmouseout="this.src='images/submitpayment_a.png'"
onmouseover="this.src='images/submitpayment_h.png'" value="Submit Payment"
url="/images/submitpayment_a.png"></h:graphicImage>
                                <rich:componentControl
for="confirmPaymentPanel" attachTo="okPayButton" operation="show"
event="onclick"/>
                             </div>
                             <div style="float:right; padding-right:10px;">
                                 <h:graphicImage id="cancelPayButton"
onmouseout="this.src='images/cancel_a.png'"
onmouseover="this.src='images/cancel_h.png'" value="Cancel"
url="/images/cancel_a.png"></h:graphicImage>
                                <rich:componentControl for="paypanel"
attachTo="cancelPayButton" operation="hide" event="onclick"/>
                            </div>
                         </div>
                           </div>
                </rich:modalPanel>
</ui:composition>
=========== End Code ==================


The expectation is that when I press the Pay button I will be sent to the
modal page a shown the current amount plus several other fields.

Unfortunately, I am unable to get the values for the row that I am
selecting.

This is a seam using faces and any help would be appreciated. I am currently
at a dead end in terms of possible ways to get this working.


Thanks
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.ajug.org/pipermail/ajug-members/attachments/20110516/87d97547/attachment-0001.html 


More information about the ajug-members mailing list