Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread mansour77


All I am trying to do is to retrieve an account from A DB and using 
taglib (data grid) to display the associated invoice with this account. 
Should this be a two-days task.


Maybe something wrong with me.

here's my controller:

package billing;
import com.opensymphony.xwork2.ActionSupport;
public class AccountManager   extends ActionSupport{

   private Account account ;
   private AccountBean accountBean ;
  
   public String execute()

   {
   account = new Account(accountBean);
   return SUCCESS ;
   }

   public AccountBean getAccountBean() {
   return accountBean;
   }

   public void setAccountBean(AccountBean accountBean) {
   this.accountBean = accountBean;
   }
}


and here's my jsp

%@ taglib prefix=s uri=/struts-tags%
%@ taglib prefix=ui uri=/taglibs-datagrid%
%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%

%@ taglib uri=http://java.sun.com/jstl/core; prefix=c1 %
%@ taglib uri=http://java.sun.com/jstl/fmt; prefix=fmt %

%@ page import=billing.* %
%@ page import=java.util.ArrayList%
[EMAIL PROTECTED] import=java.util.Collection%

html
head
/head
body

div style=background-color:lightblue;s:label value=AccId: /
s:property value=accountBean.accountNumber / br
s:label value=First Name: /
s:propertyvalue=accountBean.firstName /br
s:label value=Last Name:  /
s:propertyvalue=accountBean.lastName /
/div
hr

jsp:useBean id=accountBean type=billing.AccountBean scope=request
   beanName=billing.AccountBean
/jsp:useBean

ui:dataGrid items=${accountBean.invoices} var=i name=datagrid1
 columns
   column width=100 order=true
 header value=ID /
 item   value=${i.id}/
   /column
 columns
/ui:dataGrid 
/body
/html



Now How can I set a bean called invoices to the value of  the bean 
account.invoices ?









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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread mansour77

Laurie Harper wrote:

[EMAIL PROTECTED] wrote:


All I am trying to do is to retrieve an account from A DB and using 
taglib (data grid) to display the associated invoice with this 
account. Should this be a two-days task.


Maybe something wrong with me.

here's my controller:

package billing;
import com.opensymphony.xwork2.ActionSupport;
public class AccountManager   extends ActionSupport{

   private Account account ;
   private AccountBean accountBean ;
 public String execute()
   {
   account = new Account(accountBean);
   return SUCCESS ;
   }

   public AccountBean getAccountBean() {
   return accountBean;
   }

   public void setAccountBean(AccountBean accountBean) {
   this.accountBean = accountBean;
   }
}


Maybe this is an incomplete code sample, but you don't appear to be 
initializing accountBean, so getAccountBean() will always return null.


I dont think so, because the first part of the page is working fine and 
displaying the information I am expecting, firstName , lastName , ...
And the accountBean is set and processed in Account.java. I don't have 
any bussiness logic in AccountBean, just only the data to pass the jsp.




and here's my jsp

%@ taglib prefix=s uri=/struts-tags%
%@ taglib prefix=ui uri=/taglibs-datagrid%
%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%

%@ taglib uri=http://java.sun.com/jstl/core; prefix=c1 %
%@ taglib uri=http://java.sun.com/jstl/fmt; prefix=fmt %

%@ page import=billing.* %
%@ page import=java.util.ArrayList%
[EMAIL PROTECTED] import=java.util.Collection%

html
head
/head
body

div style=background-color:lightblue;s:label value=AccId: /
s:property value=accountBean.accountNumber / br
s:label value=First Name: /
s:propertyvalue=accountBean.firstName /br
s:label value=Last Name:  /
s:propertyvalue=accountBean.lastName /
/div
hr

jsp:useBean id=accountBean type=billing.AccountBean scope=request
   beanName=billing.AccountBean
/jsp:useBean

ui:dataGrid items=${accountBean.invoices} var=i name=datagrid1
 columns
   column width=100 order=true
 header value=ID /
 item   value=${i.id}/
   /column
 columns
/ui:dataGrid 
/body
/html



Now How can I set a bean called invoices to the value of  the bean 
account.invoices ?


Maybe I don't understand your question; it sounds like you just need 
to set accountBean.invoices in your action's execute() method:


public String execute()
{
accountBean = ... ;
accountBean.setInvoices(...);
return SUCCESS;
}

L.


-
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]



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread mansour77


Dave Newton wrote:

--- [EMAIL PROTECTED] wrote:
  

jsp:useBean id=accountBean
 type=billing.AccountBean 
 scope=request/

I don't know  exactly why I am using this, but from what I understand to 
make the variable available for the page.

Being a newbie, I decided to try every single bit of info.



is sufficient, but it's still not clear to me why
you're using jsp:useBean.../ at all.

  

ui:dataGrid items=${accountBean.invoices} [...]



If accountBean has an appropriate getInvoices() method
and whatever this taglib is you're using expects it, I
don't know (yet, anyway) what the problem would be.

  


Yes, it does have the correct getInvoices() here's the code:

   public ArrayListInvoiceBean getInvoices() {
   return invoices;
   }

I don't see anything wrong with this !

Now How can I set a bean called invoices to the
value of  the bean account.invoices ?



You have to say *what's actually happening* in order
for anybody to help you. You have to say what taglib
you're using so people that have used it can provide
input based on their prior experience. You should
probably answer my JSP 2.0 question, although that
depends somewhat on the taglib; it might not matter.
  


I am getting an exception in that taglib:

java.lang.IllegalArgumentException
   at 
org.apache.taglibs.datagrid.DataGridTag.setItems(DataGridTag.java:928)
   at 
org.apache.jsp.pages.accountView_jsp._jspx_meth_ui_005fdataGrid_005f0(accountView_jsp.java:273)




As I said: the StrutsRequestWrapper automagically
exposes OGNL stack values to JSTL; if your action has
a getAccountBean(), which it does, then
${accountBean.invoices} will get it under a JSP 2.0
container or a taglib that understands JSP EL
(assuming accountBean has a getInvoices()).
  


I think that where the problem is. I have debugged the and stepped 
through the code of the taglib: here 's the method that's throwing the 
exception in the Taglib



public void setItems (String value) throws JspException
 {
   Object obj;

   obj = ExpressionLanguageHelper.evalObject (items, value, this, 
pageContext);

   if  (obj instanceof Iterator)
 items = (Iterator) obj;
   else if (obj instanceof Object [])
 items = Arrays.asList ((Object []) obj).iterator ();
   else if (obj instanceof Collection)
 items = ((Collection) obj).iterator ();
   else if (obj instanceof Map)
 items = ((Map) obj).values ().iterator ();
   else
 throw (new IllegalArgumentException ());
 }


when I stepped into the code, I found obj is of type string 
So I assumed there's something wrong I am doing in passing the argument, 
or setting some variable ... or

Here's where my problem IS.


If you do a c:forEach.../ over
${accountBean.invoices} does it work? Things like that
are helpful to know, especially when you are dealing
with a tag library that not everybody will have used.
  


Yes I tried forEach and it's working fine and giving me the expected 
resulted. This code works as expected.



c:forEach items=${accountBean.invoices}  var=inv 
c:out value=${inv.id} /
/c:forEach



If you're still getting the TLD error then your
problem is occuring before any of the above even
matters (I think!)
  

No I am not getting this error anymore.


Help us to help you.
  
I was frustrated when I posted the original message. I should have 
included more details. Sorry and thank you.




d.



 


Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

-
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]



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread Dave Newton
--- [EMAIL PROTECTED] wrote:
 jsp:useBean id=accountBean
  type=billing.AccountBean 
  scope=request/

is sufficient, but it's still not clear to me why
you're using jsp:useBean.../ at all.

 ui:dataGrid items=${accountBean.invoices} [...]

If accountBean has an appropriate getInvoices() method
and whatever this taglib is you're using expects it, I
don't know (yet, anyway) what the problem would be.

 Now How can I set a bean called invoices to the
 value of  the bean account.invoices ?

You have to say *what's actually happening* in order
for anybody to help you. You have to say what taglib
you're using so people that have used it can provide
input based on their prior experience. You should
probably answer my JSP 2.0 question, although that
depends somewhat on the taglib; it might not matter.

As I said: the StrutsRequestWrapper automagically
exposes OGNL stack values to JSTL; if your action has
a getAccountBean(), which it does, then
${accountBean.invoices} will get it under a JSP 2.0
container or a taglib that understands JSP EL
(assuming accountBean has a getInvoices()).

If you do a c:forEach.../ over
${accountBean.invoices} does it work? Things like that
are helpful to know, especially when you are dealing
with a tag library that not everybody will have used.

If you're still getting the TLD error then your
problem is occuring before any of the above even
matters (I think!)

Help us to help you.

d.



 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread mansour77

Sorry:
Forgot about the tag lib : I am using datagrid lib from  
jakarta-taglibs-sandbox. 


Dave Newton wrote:

--- [EMAIL PROTECTED] wrote:
 

jsp:useBean id=accountBean
 type=billing.AccountBean  scope=request/

I don't know  exactly why I am using this, but from what I understand 
to make the variable available for the page.

Being a newbie, I decided to try every single bit of info.



is sufficient, but it's still not clear to me why
you're using jsp:useBean.../ at all.

 

ui:dataGrid items=${accountBean.invoices} [...]



If accountBean has an appropriate getInvoices() method
and whatever this taglib is you're using expects it, I
don't know (yet, anyway) what the problem would be.

  


Yes, it does have the correct getInvoices() here's the code:

   public ArrayListInvoiceBean getInvoices() {
   return invoices;
   }

I don't see anything wrong with this !

Now How can I set a bean called invoices to the
value of  the bean account.invoices ?



You have to say *what's actually happening* in order
for anybody to help you. You have to say what taglib
you're using so people that have used it can provide
input based on their prior experience. You should
probably answer my JSP 2.0 question, although that
depends somewhat on the taglib; it might not matter.
  


I am getting an exception in that taglib:

java.lang.IllegalArgumentException
   at 
org.apache.taglibs.datagrid.DataGridTag.setItems(DataGridTag.java:928)
   at 
org.apache.jsp.pages.accountView_jsp._jspx_meth_ui_005fdataGrid_005f0(accountView_jsp.java:273) 





As I said: the StrutsRequestWrapper automagically
exposes OGNL stack values to JSTL; if your action has
a getAccountBean(), which it does, then
${accountBean.invoices} will get it under a JSP 2.0
container or a taglib that understands JSP EL
(assuming accountBean has a getInvoices()).
  


I think that where the problem is. I have debugged the and stepped 
through the code of the taglib: here 's the method that's throwing the 
exception in the Taglib



public void setItems (String value) throws JspException
 {
   Object obj;

   obj = ExpressionLanguageHelper.evalObject (items, value, this, 
pageContext);

   if  (obj instanceof Iterator)
 items = (Iterator) obj;
   else if (obj instanceof Object [])
 items = Arrays.asList ((Object []) obj).iterator ();
   else if (obj instanceof Collection)
 items = ((Collection) obj).iterator ();
   else if (obj instanceof Map)
 items = ((Map) obj).values ().iterator ();
   else
 throw (new IllegalArgumentException ());
 }


when I stepped into the code, I found obj is of type string 
So I assumed there's something wrong I am doing in passing the 
argument, or setting some variable ... or

Here's where my problem IS.


If you do a c:forEach.../ over
${accountBean.invoices} does it work? Things like that
are helpful to know, especially when you are dealing
with a tag library that not everybody will have used.
  


Yes I tried forEach and it's working fine and giving me the expected 
resulted. This code works as expected.



c:forEach items=${accountBean.invoices}  var=inv 
c:out value=${inv.id} /
/c:forEach



If you're still getting the TLD error then your
problem is occuring before any of the above even
matters (I think!)
  

No I am not getting this error anymore.


Help us to help you.
  
I was frustrated when I posted the original message. I should have 
included more details. Sorry and thank you.




d.



 
 


Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! 
Games.

http://videogames.yahoo.com/platform?platform=120121

-
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]





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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread Laurie Harper

[EMAIL PROTECTED] wrote:


All I am trying to do is to retrieve an account from A DB and using 
taglib (data grid) to display the associated invoice with this account. 
Should this be a two-days task.


Maybe something wrong with me.

here's my controller:

package billing;
import com.opensymphony.xwork2.ActionSupport;
public class AccountManager   extends ActionSupport{

   private Account account ;
   private AccountBean accountBean ;
 public String execute()
   {
   account = new Account(accountBean);
   return SUCCESS ;
   }

   public AccountBean getAccountBean() {
   return accountBean;
   }

   public void setAccountBean(AccountBean accountBean) {
   this.accountBean = accountBean;
   }
}


Maybe this is an incomplete code sample, but you don't appear to be 
initializing accountBean, so getAccountBean() will always return null.



and here's my jsp

%@ taglib prefix=s uri=/struts-tags%
%@ taglib prefix=ui uri=/taglibs-datagrid%
%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%

%@ taglib uri=http://java.sun.com/jstl/core; prefix=c1 %
%@ taglib uri=http://java.sun.com/jstl/fmt; prefix=fmt %

%@ page import=billing.* %
%@ page import=java.util.ArrayList%
[EMAIL PROTECTED] import=java.util.Collection%

html
head
/head
body

div style=background-color:lightblue;s:label value=AccId: /
s:property value=accountBean.accountNumber / br
s:label value=First Name: /
s:propertyvalue=accountBean.firstName /br
s:label value=Last Name:  /
s:propertyvalue=accountBean.lastName /
/div
hr

jsp:useBean id=accountBean type=billing.AccountBean scope=request
   beanName=billing.AccountBean
/jsp:useBean

ui:dataGrid items=${accountBean.invoices} var=i name=datagrid1
 columns
   column width=100 order=true
 header value=ID /
 item   value=${i.id}/
   /column
 columns
/ui:dataGrid 
/body
/html



Now How can I set a bean called invoices to the value of  the bean 
account.invoices ?


Maybe I don't understand your question; it sounds like you just need to 
set accountBean.invoices in your action's execute() method:


public String execute()
{
accountBean = ... ;
accountBean.setInvoices(...);
return SUCCESS;
}

L.


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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread Dave Newton
--- [EMAIL PROTECTED] wrote:
 when I stepped into the code, I found obj is of type
 string  So I assumed there's something wrong I
am
 doing in passing the argument, or setting some 
 variable ... or Here's where my problem IS.

You still haven't said if you'r running on a JSP 2.0
container, but what it looks like is happening is that
you *are* running on JSP 2.0 so JSP itself is
evaluating the EL you're passing in and the tag
expects to eval the EL itself.

You could *try* just passing in accountBean.invoices
(rather than ${accountBean.invoices}) and see if
that works; I don't know if the taglib is expecting a
complete EL expression.

Also bear in mind that it appears to be a sandbox
project and the latest build I saw was back in Aug
2006 and the only comment on the page is from 2004; it
may not be active, supported, or play nice with JSP
2.0.

d.



 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread mansour77

Dave Newton wrote:

--- [EMAIL PROTECTED] wrote:
  

when I stepped into the code, I found obj is of type
string  So I assumed there's something wrong I


am
  
doing in passing the argument, or setting some 
variable ... or Here's where my problem IS.



You still haven't said if you'r running on a JSP 2.0
container, but what it looks like is happening is that
you *are* running on JSP 2.0 so JSP itself is
evaluating the EL you're passing in and the tag
expects to eval the EL itself.
  

Dave, thank you. I am using tomcat 6.0.2. and Jakarta-taglibs-standard-1.1.2



You could *try* just passing in accountBean.invoices
(rather than ${accountBean.invoices}) and see if
that works; I don't know if the taglib is expecting a
complete EL expression.

  

I tried this and it didn't work.

Now since it looks like I am running into compatibility issues, is there 
any alternative for this tag lib ?
I need some thing very similar that provides paging and to be as easy an 
.net control components.

Does struts provides a similar components ?


Also bear in mind that it appears to be a sandbox
project and the latest build I saw was back in Aug
2006 and the only comment on the page is from 2004; it
may not be active, supported, or play nice with JSP
2.0.

d.



 


Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

-
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]



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread Dave Newton
--- [EMAIL PROTECTED] wrote:
 Dave Newton wrote:
 You could *try* just passing in
 accountBean.invoices (rather than 
 ${accountBean.invoices}) and see if that works; I

 don't know if the taglib is expecting a complete 
 EL expression.
 I tried this and it didn't work.

Yeah, didn't think so.

 Now since it looks like I am running into
 compatibility issues, is there any alternative for 
 this tag lib ?

I have no idea; sorry.

 Does struts provides a similar components ?

Not that I know of. You could use Google and see if
there are other existing taglibs, though, or check the
archives; I'm pretty sure I've seen this topic come up
fairly frequently.

d.



 

Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food  Drink QA.
http://answers.yahoo.com/dir/?link=listsid=396545367

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



Re: Accessing a Bean from a bean using EL with STRUTS 2 - I really need help

2007-04-07 Thread Piero Sartini
On Saturday 07 April 2007 22:15:18 [EMAIL PROTECTED] wrote:
 Now since it looks like I am running into compatibility issues, is there
 any alternative for this tag lib ?
 I need some thing very similar that provides paging and to be as easy an
 .net control components.
 Does struts provides a similar components ?

There is the table-tag plugin which is currently in beta stage. Maybe this is 
what you are looking for:
http://cwiki.apache.org/S2PLUGINS/table-tags.html

Piero

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