Cezary,

First I'd say ditch the static references on your Account class. Also why are 
you extending ActionSupport on the account class? It's an entity object.

Second, create a constructor for your Settings action class. In the constructor 
check for nullity of each of the accounts, and if so then statically 
instantiate them. Also, I'm assuming BankSupport extends ActionSupport?

Then assuming you've properly configured your action class (struts.xml), send 
your browser to something like: http://localhost:8080/{project}/Settings.do

Ensure that the a successful result hits your index.jsp that you've provided 
below and you should be able render the account amounts through
%{ac1.currentAmount}

I'm not even sure if the above would work and I'm only basing it on what you've 
provided below. Someone else might correct me or even offer further elaborate 
advice :)

Regards,
Paul

-----Original Message-----
From: MarcusFenix [mailto:[EMAIL PROTECTED]
Sent: Friday, May 04, 2007 2:49 PM
To: user@struts.apache.org
Subject: [S2] sending multiple 'bank account' objects to view page


Hi,
I`m noob to S2 so be patient ;)
I`m writting simple S2 webapp - I`d like to create 'money transfer bank
system'. Theory: i have 3 accounts, and I`d like to transfer money between
them.
This`s my "Account" class:
***************
package test;
import com.opensymphony.xwork2.ActionSupport;
public class Account extends ActionSupport{

    public Account()  {
    }

    private static int currentAmount = 0;

    public static void setCurrentAmount(int _currentAmount){
        currentAmount = _currentAmount;
    }

    public static int getCurrentAmount(){
        return currentAmount;
    }
}
************
then, I create "Settings.Action" to prepare index.jsp page:
*************
package test;

public class Settings extends BankSupport{
  Account ac1, ac2, ac3;
  public Settings()  {

    }

    public String execute(){

        ac1.setCurrentAmount(500);      //I would like to start app with
those values
        ac2.setCurrentAmount(300);
        ac3.setCurrentAmount(0);
        return SUCCESS;
    }
}
**************
And this is my index.jsp page:
**************
<%@ taglib uri="/struts-tags" prefix="s" %>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><s:text name = "page.title"/></title>
    </head>
    <body>
<s:form>
    <h1><center><s:text name = "index.hello"/></center></h1>
    <p><s:text name = "index.account1"/>                       
<!--here i would like to display accounts amount.-->
     </s:form>
    </body>
</html>
**************
My question is: how could I dynamic display in index.jsp starting accounts
amount? (ac1 = 500, ac2 = 300, ac3 = 0)? Which tag i must use?

Thanks for reply!
--
View this message in context: 
http://www.nabble.com/-S2--sending-multiple-%27bank-account%27-objects-to-view-page-tf3693561.html#a10327890
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to