I have the following code:
logic:iterate id=users name=userInfo
bean:write name=users property=userName/ /logic:iterate
How can i get the first record ?
JSTL makes this easy:
c:out value=${userInfo[0].userName} /
Or, to write out only the first one while iterating the loop:
I think life would be easier if you store your Category_VO objects in a
java.util.Collection, then use JSTL forEach tag. Something like this:
%
Collection v = new Vector();
v.add( new Category_VO(cat 1) ); //Assuming your constructor takes a
String which is the shortTitle
//psuedo code.
List categoryList = Category.getList();
request.setAttribute(categories, categoryList.toArray());
logic:iterate id=category name=categories
/logic:iterate
I made the first bit up. But should give you the idea.
jsp:useBean id=categories
%
LabelValueBean[] lvArray = new LabelValueBean[] {
new LabelValueBean(label1, value1),
new LabelValueBean(label2, value2),
new LabelValueBean(label3, value3),
new LabelValueBean(label4, value4) };
request.setAttribute(lvArray, lvArray);
%
logic:iterate
Mailing List [EMAIL PROTECTED]
Sent: Wednesday, December 24, 2003 12:31 PM
Subject: Re: Easy question: iterate
//psuedo code.
List categoryList = Category.getList();
request.setAttribute(categories, categoryList.toArray());
logic:iterate id=category name=categories
/logic:iterate
I made
for this
collection
Will
- Original Message -
From: Mark Lowe [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, December 24, 2003 12:31 PM
Subject: Re: Easy question: iterate
//psuedo code.
List categoryList = Category.getList();
request.setAttribute(categories
I's iteratin'! Thanks for all the help.
- Original Message -
From: Daniel Lipofsky [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]; e-denton
Java Programmer [EMAIL PROTECTED]
Sent: Wednesday, December 24, 2003 1:07 PM
Subject: RE: Easy question: iterate
The property attribute of the tag should point to a boolean property of
the FormBean. If that property is true the box will be checked.
...unless you're using an old(er) version of the checkbox tag... I know in
the older (1.0x) versions this was rather broken (i.e. only a string of 'T'
or 'F' or
snip
Non-String Form bean properties are evil though, you'll thank yourself later
if you use Strings
/snip
+1
-Original Message-
From: Michael Ruppin [mailto:[EMAIL PROTECTED]
Sent: Saturday, 13 September 2003 04:14
To: Struts Users Mailing List
Subject: RE: Easy Question
Non-String
Sorry for emailing so many questions. My last one (i promise) is,
how do I set an html:checkbox to display as checked?
The property attribute of the tag should point to a boolean property of
the FormBean. If that property is true the box will be checked.
--
Tim Slattery
[EMAIL PROTECTED]
Non-String Form bean properties are evil though, you'll thank yourself later if you
use Strings. As long as the String is set to something sensible like true or
false, your checkbox will be properly set.
I'm sure there are ample posts on the pros cons of this approach, here's one pro
Boolean form properties are cool too (at least in my experience)...
Edgar
-Original Message-
From: Michael Ruppin [mailto:[EMAIL PROTECTED]
Sent: Friday, September 12, 2003 3:14 PM
To: Struts Users Mailing List
Subject: RE: Easy Question
Non-String Form bean properties
: Friday, September 12, 2003 3:14 PM
To: Struts Users Mailing List
Subject: RE: Easy Question
Non-String Form bean properties are evil though, you'll thank
yourself later if you use Strings. As long as the String is
set to something sensible like true or false, your
checkbox
Do you have a valid action element in your struts-config.xml file
specifying the editRecord.do action (assuming you're using extension
mapping)?
-Original Message-
From: John Mattos [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 2:29 PM
To: [EMAIL PROTECTED]
Subject:
Yes, here it is...
actionpath=/editRecord
type=com.thoughtworks.clearinghouse.web.servlet.EditRecordAction
name=recordForm
scope=request
input=editRecord.jsp
forward name=edit path=/editErrorFields.jsp/
forward name=confirm path=/prepareRecordsManagement.do/
forward
What do you mean by inside a jar file that is referenced in the
classpath explicitly? Aren't you putting your application classes in
the WEB-INF/classes or WEB-INF/lib directory? You will always get
into trouble if you try to externally control the CLASSPATH.
-Original Message-
From:
Hey
The jar file, called iNDemandCH.jar lives in this directory.
C:\Tomcat\webapps\indemand\WEB-INF\lib
the weird thing about this is that some .do actions work, and others don't. Do you
think it might be that it can't see the class files?
Karr, David [EMAIL PROTECTED] wrote:What do you mean
, 2002 3:08 PM
To: Struts Users Mailing List
Subject: RE: Easy Question
Hey
The jar file, called iNDemandCH.jar lives in this directory.
C:\Tomcat\webapps\indemand\WEB-INF\lib
the weird thing about this is that some .do actions work, and
others don't. Do you think it might
cause stack trace?
-Original Message-
From: John Mattos [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 3:08 PM
To: Struts Users Mailing List
Subject: RE: Easy Question
Hey
The jar file, called iNDemandCH.jar lives in this directory.
C:\Tomcat\webapps\indemand\WEB
-
From: John Mattos [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 26, 2002 3:08 PM
To: Struts Users Mailing List
Subject: RE: Easy Question
Hey
The jar file, called iNDemandCH.jar lives in this directory.
C:\Tomcat\webapps\indemand\WEB-INF\lib
the weird thing about
20 matches
Mail list logo