You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ma...@yahoo.com on 2007/04/07 21:08:39 UTC

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

Dave Newton wrote:
> --- mansour77@yahoo.com 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 ArrayList<InvoiceBean> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by ma...@yahoo.com.
Sorry:
Forgot about the tag lib : I am using datagrid lib from  
jakarta-taglibs-sandbox. 
>
> Dave Newton wrote:
>> --- mansour77@yahoo.com 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 ArrayList<InvoiceBean> 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: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Mansour <ma...@yahoo.com>.
Piero, Thank you. I think this is very close to what I need, if not, maybe I can just modify it a bit.



Piero Sartini wrote:
> On Saturday 07 April 2007 22:15:18 mansour77@yahoo.com 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Piero Sartini <li...@pierosartini.de>.
On Saturday 07 April 2007 22:15:18 mansour77@yahoo.com 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Dave Newton <ne...@yahoo.com>.
--- mansour77@yahoo.com 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 Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by ma...@yahoo.com.
Dave Newton wrote:
> --- mansour77@yahoo.com 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Dave Newton <ne...@yahoo.com>.
--- mansour77@yahoo.com 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org