Re: calling method of a bean from JSP

2006-09-18 Thread Yujun Liang

I only used String as key.

   public Object getStringMapped(String key) {
   return map.get(key);
   }

   public void setStringMapped(String key, Object value) {
   map.put(key, value);
   }



Regards

On 9/18/06, Lixin Chu [EMAIL PROTECTED] wrote:


On 9/17/06, Yujun Liang [EMAIL PROTECTED] wrote:

 Have you tried Mapped Properties?
 http://struts.apache.org/1.2.9/faqs/indexedprops.html

 Regards


this is a good point. I have not tried it. Is it ok (in terms of
performance) to use a custom class as the key, not using Java primitives
like Long ?





--
Yujun Liang
[EMAIL PROTECTED]


Re: calling method of a bean from JSP

2006-09-17 Thread Yujun Liang

Have you tried Mapped Properties?
http://struts.apache.org/1.2.9/faqs/indexedprops.html

Regards

On 9/16/06, Strachan, Paul [EMAIL PROTECTED] wrote:


you could move the logic into the view/jsp layer...something like:

c:forEach items=${item.values} var=value
  c:if test=${value.attribute.id == 'id'}
c:out value=${value.value} /
  /c:if
/c:forEach

or maybe a custom tag library...






From: Lixin Chu [mailto:[EMAIL PROTECTED]
Sent: Sat 16/09/2006 1:25 PM
To: Struts Users Mailing List
Subject: Re: calling method of a bean from JSP



i do not think it works.


**
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**

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





--
Yujun Liang
[EMAIL PROTECTED]


Re: calling method of a bean from JSP

2006-09-17 Thread Lixin Chu

this should work. thanks !

On 9/16/06, Strachan, Paul [EMAIL PROTECTED] wrote:


you could move the logic into the view/jsp layer...something like:

c:forEach items=${item.values} var=value
c:if test=${value.attribute.id == 'id'}
   c:out value=${value.value} /
/c:if
/c:forEach

or maybe a custom tag library...






From: Lixin Chu [mailto:[EMAIL PROTECTED]
Sent: Sat 16/09/2006 1:25 PM
To: Struts Users Mailing List
Subject: Re: calling method of a bean from JSP



i do not think it works.


**
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**

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




Re: calling method of a bean from JSP

2006-09-17 Thread Lixin Chu

On 9/17/06, Yujun Liang [EMAIL PROTECTED] wrote:


Have you tried Mapped Properties?
http://struts.apache.org/1.2.9/faqs/indexedprops.html

Regards



this is a good point. I have not tried it. Is it ok (in terms of
performance) to use a custom class as the key, not using Java primitives
like Long ?


RE: calling method of a bean from JSP

2006-09-16 Thread Strachan, Paul
you could move the logic into the view/jsp layer...something like:
 
c:forEach items=${item.values} var=value
  c:if test=${value.attribute.id == 'id'}
c:out value=${value.value} /
  /c:if
/c:forEach
 
or maybe a custom tag library...
 
 
 



From: Lixin Chu [mailto:[EMAIL PROTECTED]
Sent: Sat 16/09/2006 1:25 PM
To: Struts Users Mailing List
Subject: Re: calling method of a bean from JSP



i do not think it works.


**
This message is intended for the addressee named and may contain
privileged information or confidential information or both. If you
are not the intended recipient please delete it and notify the sender.
**

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



Re: calling method of a bean from JSP

2006-09-15 Thread Laurie Harper

Lixin Chu wrote:



What are you trying to achieve? Maybe you're trying to put logic in your
JSPs that more properly belongs in an action.



thanks. what i am trying to do is to get the value of a field. Say I get a
list of items:

class item {
Set values;

}

The item has a set of Values:
class Value {
Attribute attribute;
String value;
}

What I wanted to do is to get one particular value based on attribute 
ID. in

this case I have to add a method in the Item class, someting like this:

String getValue (String id) {
 while (it.hasNext()) {
Value value = (value) it.next();
if (value.attribute.getId().toString().equals (id)
   return value.value;
 }

So from JSP, I would like to call this method c:out value=${item.getValue
(id}/


c:out value=${item.value[id]}/ ?

L.


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



Re: calling method of a bean from JSP

2006-09-15 Thread Lixin Chu

i do not think it works.


Re: calling method of a bean from JSP

2006-09-14 Thread Laurie Harper

Lixin Chu wrote:

c:out value=${beanName.methodName}/

I thought this is for getting the value of a property ?  and how to pass a


Yes.


parameter  to the method ? I think I have tried that but does not work.


You can't invoke arbitrary bean methods with EL; it's designed for 
accessing properties, not calling arbitrary methods. The closest you can 
come is to 'fake' a map-type Foo.getBar(String key) property so you 
could write ${foo.bar[param]}, but that's a bit limitted.


What are you trying to achieve? Maybe you're trying to put logic in your 
JSPs that more properly belongs in an action.


L.


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



Re: calling method of a bean from JSP

2006-09-14 Thread Lixin Chu



What are you trying to achieve? Maybe you're trying to put logic in your
JSPs that more properly belongs in an action.



thanks. what i am trying to do is to get the value of a field. Say I get a
list of items:

class item {
Set values;
...
}

The item has a set of Values:
class Value {
Attribute attribute;
String value;
}

What I wanted to do is to get one particular value based on attribute ID. in
this case I have to add a method in the Item class, someting like this:

String getValue (String id) {
 while (it.hasNext()) {
Value value = (value) it.next();
if (value.attribute.getId().toString().equals (id)
   return value.value;
 }

So from JSP, I would like to call this method c:out value=${item.getValue
(id}/


Re: calling method of a bean from JSP

2006-09-13 Thread Monkeyden

c:out value=${beanName.methodName}/

or

c:set var=myVar value=${beanName.methodName}/



On 9/12/06, Lixin Chu [EMAIL PROTECTED] wrote:


Hi,
would like to check if there is existing tag available to allow method
invocation from JSP directly, something similar to this :
Call JavaBean methods from JSP 2.0 pages 

http://www.javaworld.com/javaworld/jw-05-2003/jw-0523-calltag.html

thanks
lx




Re: calling method of a bean from JSP

2006-09-13 Thread Lixin Chu

c:out value=${beanName.methodName}/


I thought this is for getting the value of a property ?  and how to pass a
parameter  to the method ? I think I have tried that but does not work.


calling method of a bean from JSP

2006-09-12 Thread Lixin Chu

Hi,
would like to check if there is existing tag available to allow method
invocation from JSP directly, something similar to this :
Call JavaBean methods from JSP 2.0 pages 

http://www.javaworld.com/javaworld/jw-05-2003/jw-0523-calltag.html

thanks
lx