Trouble with struts tags
Hi,
I am new to struts and am getting confused with the tags.
I have few doubts.
My Actionform would be -
public class AForm extends ActionForm {
//~ Instance fields ********************************************************
String deptNo;
String dName;
String loc;
//~ Methods ****************************************************************
* This function
* @param deptNo DOCUMENT ME!
public void setDeptNo(String deptNo) {
this.deptNo = deptNo;
* This function
* @return DOCUMENT ME!
public String getDeptNo() {
return deptNo;
}In my action class I say -
selectSql = "SELECT DEPTNO FROM DEPT";
pStmt = conn.prepareStatement(selectSql);
theResultSet = pStmt.executeQuery();
ArrayList _arrayList = new ArrayList();
while (theResultSet.next()) {
AForm theAForm = new AForm();
theAForm.setDeptNo(theResultSet.getString("DEPTNO"));
_arrayList.add(theAForm);
req.setAttribute("arrayListOfDeptnos", _arrayList);My question is -
How do I get this arraylist in the JSP and iterate through it? Should I code in this way? Is there an more elegant way to do it??
My JSP page
<%
java.util.ArrayList ss = (java.util.ArrayList)request.getAttribute("arrayListOfDeptnos");
if(ss!=null){
%>
<logic:iterate id="booId" scope="request" collection="<%=ss%>" type="mypackage27.AForm">
<html:link action="/getme" paramId="theNum" paramProperty="deptNo" paramName="booId">
<bean:write name="booId" property="deptNo"/>
</html:link>
</logic:iterate>
<%
%>I know this must be very trivial ...
Rather than using collection attribute (which requires a runtime expression) instead use the name attribute.
Also, if you aren't going to use the variable "booId" in scriptlet code/expressions, you can leave out the "type" attribute.
Probably the scope attribute as well.
That all boils down to:
<logic:iterate id="booId" name="arrayListOfDeptnos">
<html:link action="/getme" paramId="theNum" paramProperty="deptNo" paramName="booId">
<bean:write name="booId" property="deptNo"/>
</html:link>
</logic:iterate>And for completeness, the same thing using some JSTL code:
<c:forEach var="booId" items="${requestScope.namearrayListOfDeptnos}">
<html:link action="/getme" paramId="theNum" paramProperty="deptNo" paramName="booId">
<c:out value="${booId.deptNo}"/>
</html:link>
</c:forEach>Cheers,
evnafets
Similar Messages
-
Problem compling JSP with struts tags on Weblogic 8.1
I have deployed a web application in Weblogic 8.1. However, I am facing a problem while the JSPs are getting compiled. The JSPs ahve taglib declarations referring to Struts tag library files that are present in WEB-INF folder.
Stacktrace:
C:\java\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_epgonline_epgonline\jsp_servlet\_approve\__approve_home.java:209: cannot resolve symbol
probably occurred due to an error in /approve/approve_home.jsp line 53:
<logic:notPresent name="<%=JobBean.ID%>" scope="request">
C:\java\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_epgonline_epgonline\jsp_servlet\_approve\__approve_home.java:209: cannot resolve symbol
symbol : variable EVAL_BODY_BUFFERED
location: interface javax.servlet.jsp.tagext.BodyTag
if (_int0 == BodyTag.EVAL_BODY_BUFFERED) { //[ /approve/approve_home.jsp; Line: 53]
I believe other people have also faced this issue with Weblogic8.1 and struts. Any solutions???
Thx
KPKP,
Does this code run in the development environment but not in production? How
was this code compiled?
- john
"KP" <[email protected]> wrote in message
news:405b9b56$[email protected]..
I have deployed a web application in Weblogic 8.1. However, I am facing aproblem while the JSPs are getting compiled. The JSPs ahve taglib
declarations referring to Struts tag library files that are present in
WEB-INF folder.
Stacktrace:
C:\java\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\m
yserver_epgonline_epgonline\jsp_servlet\_approve\__approve_home.java:209:
cannot resolve symbol
probably occurred due to an error in /approve/approve_home.jsp line 53:
<logic:notPresent name="<%=JobBean.ID%>" scope="request">
C:\java\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\m
yserver_epgonline_epgonline\jsp_servlet\_approve\__approve_home.java:209:
cannot resolve symbol
symbol : variable EVAL_BODY_BUFFERED
location: interface javax.servlet.jsp.tagext.BodyTag
if (_int0 == BodyTag.EVAL_BODY_BUFFERED) { //[/approve/approve_home.jsp; Line: 53]
>
I believe other people have also faced this issue with Weblogic8.1 andstruts. Any solutions???
>
Thx
KP -
JDeveloper editing JSP with Struts tags terribly, terribly slow!?
I use JDeveloper 10.1.2 and I do not know the reason but it started to take 15min just to change/edit JSP containing Struts tags. RAM memory is 1GB and there is more than 0.5 GB available, but processor usage shows 100% allocated to JDeveloper!? As soon as I do even slight change in a JSP file JDeveloper starts some computations and I have no idea of what it is doing.
What is JDeveloper computing? It seems it tries to produce some drop-down lists "helping" me to do the editing, add tags and instead I am spending days to just change one small JSP page!
How can I stop and PREVENT JDeveloper doing ANY "help" during editing of ANY file?
There must be an option to switch off whatever JDeveloper is doing?
Many thanks,I did that but it is still very slow, it looks like Jdev is doing some intensive calculations whenever I click somewhere on JSP page with tags. Maybe this is related with my other question I posted before this one? Maybe JDev automatically searches for tag libraries it cannot find and copies them to /WEB-INF directory? (other IDEs used in same environment, like Eclipse and IntelliJ, and they do not have this problem)
Some other strange things: struts-config.xml seems not integrated with CVS from JDev (other files like tiles-config.xml, web.xml etc. are integrated, I can right click and get CVS info on particular file, except struts-config.xml). When I want to check in/out struts-config.xml I have to do it with external tool like WinCVS etc., cannot do that from JDev! -
Help! Problem with Struts tag html:errors/
Hi everybody,
In my JSP page called addUser.jsp, i have the different Struts Tag
<html:errors/>
<html:form action="/addUser" focus="firstName">
</html:form>
I have of course the ApplicationResources.properties file with differents Struts properties:
errors.footer=</ul><hr>
errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
errors.ioException=I/O exception rendering error messages: {0}
and an other one:
error.fieldsNeeded=<font color="#FF0000">Some fields are missing.</font>
when I call the addUser form, my JSP page display:
null Some fields are missing. null
Have u any suggestion about my prob?
tx a lot
s.Hi,
can u post the java code where u are actually adding the error to the action errors. may be there is something wrong with that. I dont see any problem with the jsp or the applicationsResources.properties.
Thanks
Latha -
Hello Friends,
I'm very new to struts, and have a code piece that does the following:
<logic:iterate id="paramData" name="<%=printParam%>" >
<PARAM NAME = "<bean:write name="paramData" property="key" />" VALUE="<bean:write name="paramData" property="value" />">
<PARAM NAME = "rootUrl" VALUE="<%=HttpUtil.getServerUrl(request)%>" >
</logic:iterate>
It iterates through a Map and gets the values in the applet. However I now have to change this so that it gets the applet params from a ParamsVO.java, a value object. How does the code change to get the values now?
I have paramsvo.getXXX methods that I can use. Though not sure how they are used with struts. Pls help!!
KarenAll the parameters are in this ParamsVO object? Each with their own getter/setter?
I don't think you are able to do this in a loop.
You just have to write a <PARAM> tag for each property, and get its value.
For instance if paramsVO has getParam1() method
<PARAM NAME="param1" VALUE="<bean:write name="paramVO" property="param1"/>">
Cheers,
evnafets -
Help: OJSPC can not compile the JSP with struts tag
Hi,
I am trying to precompile the JSP page with EAR package but OJSPC can not parse the Struts tags.
I always get oracle.jsp.parse.JspParseException:
Error: org.apache.struts.taglib.html.MessgesTei while reading TLD /WEB-INF/tld/struts-html.tld
My OC4J version is 10.1.3.2 and I did tried putting the struts-taglib.jar to /opt/oracle/product/app10g/j2ee/home/jsp/lib or /lib/taglib
but still do not work.
Can anyone tell me how to configure the OJSPC and let it support customerized taglibs?
Thanks a lot!This is a new problem with jdk1.4 when compiling with tomcat.
The solution is to ensure that any classes in WEB-INF/classes are in a package structure and the relevant jsp calls the same using the package name.
best
kev -
Trouble with MergeFormat tags appearing in Word doc
Hello! I have been living with this problem for ages, and
just manually deleting them. But, I now have a new coworker who
does not get the same problem when we single-source the same
project to Word.
When I create a single-source Word document, before each
topic heading in the newly generated Word doc, I get a tag like
this: { XE "GPA:setting up" \MERGEFORMAT} I get one for each index
entry for the topic. I do not generate an index when I generate
printed docs. I'm trying to figure out where to get rid of these.
It looks like a Word setting. My coworker and I have looked at all
of our options in both Robo and Word, and can't seem to find which
one made hers go away.
I use RH7 and Word 2003.
Any ideas? Thank you for your help in advance.Sorry - I think I figured it out. I have to look at
formatting (Show/Hide Formatting) when I use Word, she does not. I
see now that the index entry tags don't print when you print the
Word docs (so I don't need to delete them) - but they are ugly to
look at as you are editing! Not sure if there is any other way to
view all other formatting marks without those. As long as I don't
have to delete them all anymore, and they don't appear in the
printed docs, I'm happy.
Thanks anyway. -
how do i print this arraylist using tags in struts... i mean using iterate and bean write tags.
<%
java.util.ArrayList alist= new java.util.ArrayList();
java.util.HashMap map = new java.util.HashMap();
map.put("ID","1");
map.put("GUID","101010101");
map.put("STAT","01");
java.util.HashMap map2 = new java.util.HashMap();
map2.put("ID","2");
map2.put("GUID","202020202");
map2.put("STAT","02");
java.util.HashMap map3 = new java.util.HashMap();
map3.put("ID","3");
map3.put("GUID","303030303");
map3.put("STAT","03");
alist.add(map);
alist.add(map2);
alist.add(map3);
System.out.println("Arraylist:"+alist);
session.setAttribute("array",alist);
%>i need to print that alist in a tabular fashion..... like this
ID GUID STATUS
1 1010101 01
2 2020202 02
3 3030303 03how do i do that
plz help
praneethhow do i print this arraylist using tags in struts... i mean using iterate and bean write tags.
<%
java.util.ArrayList alist= new java.util.ArrayList();
java.util.HashMap map = new java.util.HashMap();
map.put("ID","1");
map.put("GUID","101010101");
map.put("STAT","01");
java.util.HashMap map2 = new java.util.HashMap();
map2.put("ID","2");
map2.put("GUID","202020202");
map2.put("STAT","02");
java.util.HashMap map3 = new java.util.HashMap();
map3.put("ID","3");
map3.put("GUID","303030303");
map3.put("STAT","03");
alist.add(map);
alist.add(map2);
alist.add(map3);
System.out.println("Arraylist:"+alist);
session.setAttribute("array",alist);
%>i need to print that alist in a tabular fashion..... like this
ID GUID STATUS
1 1010101 01
2 2020202 02
3 3030303 03how do i do that
plz help
praneeth -
I manually add the tags meta name="description" and meta
name="keywords" to the html code in RH7. Then when I save the file
it strips out the quote marks around the words "description" and
"keywords". Then when I compile as WebHelp the tags are completely
removed. What is up with this? Surely there must be a way to use
these common tags in RH.Hi Esch
You might try making the following changes. Note that
Dreamweaver likely added its own Meta tag to state what the editor
was. RoboHelp does something similar. So perhaps change the
RoboHelp meta tag to reflect Dreamweaver. Sort of "fooling"
RoboHelp into thinking Dreamweaver created the topic. You would
also probably want to remove any other RoboHelp specific tags just
in case. (I think there are two or three others. Maybe more.)
My thought here is that if you could trick RoboHelp into
believing Dreamweaver created the page it would leave it alone.
Assuming, of course, that your observation is spot on with RoboHelp
leaving the tags alone.
Cheers... Rick -
I have tagged individual elements of text within a text box with tags from an imported xml file. When I import another xml file with the exact same tags but different content two of my tagged elements won't update. I have tried untagging and retagging and I can't get it to update with the new content. Another bit of info is that I have another text box with some of the same tags in it and that one will update just fine. Can anyone tell me what I am missing?
Thanks.
ChadRather than using collection attribute (which requires a runtime expression) instead use the name attribute.
Also, if you aren't going to use the variable "booId" in scriptlet code/expressions, you can leave out the "type" attribute.
Probably the scope attribute as well.
That all boils down to:
<logic:iterate id="booId" name="arrayListOfDeptnos">
<html:link action="/getme" paramId="theNum" paramProperty="deptNo" paramName="booId">
<bean:write name="booId" property="deptNo"/>
</html:link>
</logic:iterate>And for completeness, the same thing using some JSTL code:
<c:forEach var="booId" items="${requestScope.namearrayListOfDeptnos}">
<html:link action="/getme" paramId="theNum" paramProperty="deptNo" paramName="booId">
<c:out value="${booId.deptNo}"/>
</html:link>
</c:forEach>Cheers,
evnafets -
WLS 8.1 sp1 with Struts 1.1 JSP with bean tag won't compile
Hello,
We are currently porting our application which uses struts 1.1 to WLS 8.1 sp1
from another app server. Everything seems to deploy correctly and pages which
use struts tags appear to compile and run fine. However, the pages with struts
<bean:define> tags are not compiling.
Example JSP Code:
<bean:define id="userForm" name="userForm" scope="session" toScope="page" type="UserFormBean"/>
<% if (userForm.hasUserData()) {hasUser=true;} %>
WLS Console Output:
..jsp_servlet\_jsp\_sailor\__home.java:493: cannot resolve symbol
symbol : variable userForm
location: class jsp_servlet._jsp._sailor.__home
if (userForm.hasUserData()) { //[ /jsp/sailor/home.jsp; Line: 38]
When I look at the JSP's parsed java code (__home.java:493) I find that nowhere
in the class is the variable userForm declared.
Is this a bug in WLS? Does anyone know of a workaround?
Thanks,
Scott
Please contact customer support [email protected] and request a patch for
CR112789. AT_END tags do not work correctly in 81sp1
--Nagesh
"Scott Fleming" <[email protected]> wrote in message
news:3f734c0d$[email protected]..
>
> Hello,
>
> We are currently porting our application which uses struts 1.1 to WLS 8.1
sp1
> from another app server. Everything seems to deploy correctly and pages
which
> use struts tags appear to compile and run fine. However, the pages with
struts
> <bean:define> tags are not compiling.
>
> Example JSP Code:
>
> <bean:define id="userForm" name="userForm" scope="session" toScope="page"
type="UserFormBean"/>
>
> <% if (userForm.hasUserData()) {hasUser=true;} %>
>
> WLS Console Output:
>
> ..jsp_servlet\_jsp\_sailor\__home.java:493: cannot resolve symbol
> symbol : variable userForm
> location: class jsp_servlet._jsp._sailor.__home
> if (userForm.hasUserData()) { //[ /jsp/sailor/home.jsp; Line:
38]
>
> When I look at the JSP's parsed java code (__home.java:493) I find that
nowhere
> in the class is the variable userForm declared.
>
> Is this a bug in WLS? Does anyone know of a workaround?
>
> Thanks,
> Scott
-
Hi
I would like to create a custom tag that will print this section of html with struts:<tr>
<td class="f_name"><bean:message bundle="fields" key="firstName" /></td>
<td class="f_value"><html:text property="firstName" /></td>
</tr>This means that i sould pass to the custom tag the folowing attributes:
1. bundle - the bundle name to use ("fields").
2. property - the name of the submitted filed and the key in the bundle resource ("firstName").
This is how i want to use it:<html:form action="/register.do" enctype="UTF-8">
<table cellspacing="0" cellpadding="0" border="0" class="t_details">
<mytld:text bundle="fields" key="firstName"/>
<mytld:text bundle="fields" key="lastName"/>
</html:form>For me, this way looks much easier to develop my application/s, don't you agree?
The problem is that i can't (or i don't know how) to use custom tags in other a custom tag, and if i include a jsp file (with pageContext.indlude("url");), how do i pass the attributes to the jsp page?
Thanks a lot
mamtzInteresting answer, i'll put it in my mind, but this is not what i ment :) (nice thinking...)
what i ment was, html:text tag has many attributes like: property, name, alt, size, maxLength and so on...
i would like sometimes to use size or maxLength and sometimes not.
take a look at what i wrote:<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%
String property=""+request.getAttribute("property");
String bundle=""+request.getAttribute("bundle");
Object max=request.getAttribute("maxLength");
String maxLength= max==null ? "" : ""+max;
Object s=request.getAttribute("size");
String size= s==null ? "" : ""+s;
%>
<tr>
<td class="f_name"><bean:message bundle="<%=bundle%>" key="<%=property%>" /></td>
<% if(max!=null && s!=null){
%> <td class="f_value"><html:text property="<%=property%>" maxlength="<%=maxLength%>" size="<%=size%>" /></td>
<% }else if(max!=null){
%> <td class="f_value"><html:text property="<%=property%>" maxlength="<%=maxLength%>" /></td>
<% }else if(s!=null){
%> <td class="f_value"><html:text property="<%=property%>" size="<%=size%>" /></td>
<% }else{
%> <td class="f_value"><html:text property="<%=property%>" /></td>
<% }
%> </tr>pretty complicated, is'nt it?
think what would happen if i would like to add just one more attribute... -
How can I evaluate if a collection is empty or not with struts logic tag?
How can I evaluate if a collection is empty or not with struts logic tag?
I tried with logic empty tag. but the tag evaluated if a collection is null or not.
I would like to do like this below.
List list = new ArrayList();
set(list);
<logic:XXXX name="someForm" property="list">
The list size is 0.
</logic>thanks in advance.U can use :
<logic:present name="urform" property="urlist">
</logic:present>
to check "urlist" is empty or not -
Standard J2EE MVC training using Struts with Standard Tags (JSTL)
-We have done more Struts training than anyone. This class adds Standard Tag Libs (JSTL) with MVC and a portal discussion.
Full Syllabus is at :
http://www.basebeans.com/syllabus.jsp
NYC on 8/2.
This is the last week to sign up :
http://www.basebeans.com/classReservation.jsp
More dates(tentative):
8/9 - Chicago downtown Marriott
8/16 - Atlanta downtown Marriott
8/23 - Austin downtown Marriott
To keep up on upcoming MVC training sign up at:
http://www.basebeans.com:8081/mailman/listinfo/mvc-programmers
Hope to see you,
Thanks,
Vic
Ps. 1: Set your newsreader such as Outlook Express or Netscape to news.basebeans.com for Open Standard news groups like JDO, Apache, SOAP, etc.
Ps 2: The sample app will be available end of next week at:
http://www.basebeans.com/downloads.jspi have same problem with
CLI130 Could not create domain, domain1
then i try these things with PATH stuff but it haven't worked for me...
then i tried to search windows registry for string domain1 and nothing found...
then i searched my profile directory (on windowsxp c:\Documents and Settings\user on linux /home/user) for files that containd string domain1 and i found some .adadmin* files (as i remember there were 3 files) then i deleted them, try to install sun app server and it works for me... there are still some warnings but at least installation finishes and files were not deleted...
i hope this help...
for me it does -
How to prepare Custom tag with scope as session like Struts tag
Hi
All Struts tags having the feature of Automatic Scoping.
Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
regards
jaganHi
All Struts tags having the feature of Automatic Scoping.
Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
regards
jagan
Maybe you are looking for
-
I'm installing windows 8 64 from iso dvd-I did the partition wiht BCamp 5. I did the usb drive with the compatibility software-once installation start from the dvd, it ask me for some disk, usb or dvd drivers to continue. How I can continue the insta
-
How to get IDoc number using sdata records
Hi Experts, I have executed a report program in background. Its generating few IDoc's. I can view those idoc's in WE05 also. But now i want to display those idoc number in the result output of the report. One of the segment having materrial number an
-
i recently bought an i phone 5, but in the home with wireless internet access , it is continued when off, sometimes can not working, i do not know what reason, but i went to apple store, Ha, the phone can go to Wi - Fi and connected is good.
-
PS3 charge cable for Apple TV?
Can I connect the Apple TV to my mac by using the PlayStation 3 charge cable? Or do I need to buy an other cable?
-
I just upraded to 7.02 and it is SOOOOOO SLOW doing any task! Anyone have any tips on how to make it run faster? I'm using DSL speed 54.0 Mbps. I have unchecked the update album artwork automatically button. I'm out of ideas! Thanks.