Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

JD Thompson

Greenhorn
+ Follow
since Jun 29, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by JD Thompson

Daniel,

Thanks tons for your input!! That is a great suggestion and I will pass it on to the rest of the project team.

Merry Christmas!!!

JD
13 years ago
I am having to get database information to initialize the Form values in the loadForm method. One such method throws an exception. How do I handle errors to be displayed when the form is being initialized?

[I recognize that having the Form throw an exception for the calling action class to catch is ONE answer, is there another way?]

Struts provides the ActionErrors/ActionMessages for the Action class, but what structure exists for the Form class of Struts?

Below is a VERY skeletal representation of what I am facing:

public class TestForm extends ActionForm
{
ArrayList states;

public TestForm loadForm()
{
states=new ArrayList();
states=someDBmethodCall();
}
}
13 years ago
Jan and Merrill,

Thank you both for your thoughts and suggestions!! I agree the situation is less than ideal but you have definitely helped me out in terms of having another plan of attack (i.e. overriding the reset method).

I will let you know if success is reached!

Take care and have a great weekend!!

JD
13 years ago
We are using Struts for a J2EE 1.4 application. On the server side, I have to initialize a Strut form's values/fields BEFORE the associated Action is called. The way the lead tech has designed the architecture, this is my challenge.

The only way I can initially see how to handle this is to load the form's values as part of a constructor for the form. However, I don't know how to reach the session object.

Is there a way to call the container and receive a collection of objects, do a search for instanceof session and then retrieve the needed ejb from there?

Thanks for your help in advance!!!

JD
13 years ago
Merrill,

Once again you have proven your stuff. I followed your advice and created a basic structure like you suggested, and voila!, the values are stored.

Thanks again for your time and clear/concise response!!

JD
14 years ago
Currently, with the referenced code below, the selected value on the page IS NOT being saved on the ActionForm with the property listed. Any ideas as to why? Thanks to all!



<logic:iterate name="ReportListForm" property="reportChosen.groups" id="groups">
<logic:iterate name="groups" property="parms" id="parmValues" >
<c:set var="dataName" value="${parmValues.dataType}" />
<c:if test="${dataName=='multipleSelect'}">
<td>
<html:select indexed="true" size="10" name="parmValues" property="value" multiple="true">

<html ptionsCollection name="parmValues" property="choicesList" />

</html:select>
</td>
</c:if>
</logic:iterate>
</logic:iterate>

terms explained
--------------------------------
ActionForm="ReportListForm"
reportChosen = Report class that stores information
groups = ArrayList property of Group types, property of reportChosen
parms = ArrayList property of Parm types, property of groups
dataType = lets me know which type of html element to created for user input
multipleSelect = identifier for a select list with multiple=true
choicesList = ArrayList of choices (type = LabelValueBeans to populate lists)
------------------------------------

Thanks for your assistance. I am stumped!

JD
14 years ago
Hi Sreenath!!

Thank you very much for your reply. I will look into the URLConnection class and see how that works.

I believe I understood your advice in that I really don't have to worry about HTTP. Instead, just a straight URL with parameters.

I think I also understood that once I receive the response, use a ServletOutletStream to send to a new browser window.

Again, thank very much for taking time to help!!

Best regards!

JD
14 years ago
Basic Project Flow:
1. User selects a report name (reportList.jsp)

2. ReportListAction then populates the ReportListForm with the appropriate parameters to be selected (optional) or filled out (mandatory)

3. reportList.jsp is redisplayed (tiles configuration)with a new visible section for the user to enter parameter choices, user submits

4. ReportListAction recognizes the submittal and is suppose to do the following:

-> create an URL to submit to the Crystal Reports Server
-> submit URL
-> receive report response(suppose to be in HTML)
-> pass response through to a NEW browser window for viewing

PROBLEM STATEMENT:
How do I, internal to the ReportListAction, submit the URL? What general order do I need to follow? For example, do I create a HTTPClient and have that handle the request submittal and receive the response? Or should I use HttpURLConnection? I have looked over the APIs (HTTPRequest, HTTPClient, HTTPServletRequest, HTTPSession, etc.) but am not familiar enough with HTTP to know which to try first. This is my first time attempting to use HTTP.

ENVIRONMENT:
Developing in RAD, J2EE.

DISCLAIMER:
I was unsure as to which forum to initially post (I/O, Java Advanced, Struts) as the problem seems to touch all areas. Please accept my apology if I posted incorrectly.

Thanks for your input and advice!

JD
14 years ago
Okay, I have found a solution [took me two days to work through all of the subleties] and will post it here. I did not find alot of "clear" examples out there so hopefully this will help someone else at least once!

Your index.jsp should be setup as follows:

index.jsp
===============================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<logic:forward name="forwardToGlobalForward" />
===============================================================
NOTE: the name attribute is the name of the GLOBAL FORWARD



Modify your struts-config.xml as follows:

struts-config.xml
===============================================================
<!-- Global Forwards -->
<global-forwards>
<forward
name="forwardToGlobalForward"
path="/actionMappingToGoToNext.do"
redirect="true"/>
</global-forwards>


<!-- Action Mappings -->
<action-mappings>
<action
path="/actionMappingToGoToNext"
type="actionClassToBeExecutedBeforePageRendered">
<forward name="success" path="jspToBeRenderedAndFirstSeenByUser" />
</action>
</action-mappings>

The last thing to be sure of is to reference "success" in your mapping.findForward("success") part of your Action class.

Systems: IBM Rational, Struts 1.1, WebSphere 5.1 Server

In terms of path references, there may be inconsistencies from one IDE to the next where the slash/ is concerned for the path. I found that including it as a relative mark was causing problems in Rational but other online examples with Tomcat had the slash.

I sincerely hope this helps someone else along the way.

Bartender Merrill, I hope I did not overstep my bounds by posting my solution here.

Take care all!!
14 years ago
Thanks for the quick reply Eric.


You are right, the display design is thwarted. I tried the zIndex=5.

When I have a <Select size=1>, there is a dropdown list that appears. However with <Select size=1 multiple> I do not get one, rather scroll bars. What type of javascript coding do I need to look at in order to combine the two? (Please remember I am new as of Monday to javascript, I am not asking someone to code this for me, but detailed direction would be extremely helpful) My guess would be:

<Select onFocus=someScriptName(this) onSelect=selectStatus(passSelection)
size=1 multiple>

javascript
================================
var selectArray //create a 2 x 170 array to hold [names,selection status]

function someScriptName(passedSelectElement)
{
iterated through the passedSelectElement to populate selectArray
get x,y positioning from passedSelectElement
open new window (size big enough to hold 15 entries)
position window at x-passedSelectElement.height,y
make window scrollable
make window visible
}

function selectStatus(passedSelectElement)
{
iterate through selectArray for passedSelectElement
set element to [name,true]
}

Am I on the right track or building a mansion to house a dog?

Thanks again for your help!

JD
Sorry about the double posts, I accidentally hit the tab/enter in sequence which posted the request incomplete.....


The previous listed the index.jsp I am trying to forward through along with the applicable struts part which I am trying to reach IndexAction.

IndexAction (VERY skeletal!)
==================================================================
public class IndexAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value

try {
// do something here
}
catch (Exception e) {
errors.add("name", new ActionError("id"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
forward = mapping.findForward("success");
}
return (forward);
}
}
==================================================================

Anticipated action:

1. the index.jsp is called from another site
2. the <logic:forward> tag is executed
3. the global forward then sends control to "startReportSelect.do"
4. the action-mapping for "startReportSelect.do" then calls the Action
5. the Action, "IndexAction", then executes the preprocessing required
6. after the global variables completed, the "reportSelect.jsp" is rendered


Errors received:
Error 404: File not found: null

Oh great Struts Guru, what simple fragment/quote/logic am I missing?

Thanks for your help!!!

Take care!

JD
14 years ago
index.jsp
===============================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<logic:forward name="forwardToReportSelect" />
===============================================================

struts-config.xml
===============================================================
<!-- Global Forwards -->
<global-forwards>
<forward
name="forwardToReportSelect"
path="startReportSelect" />
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action
path="/startReportSelect.do"
type="IndexAction"
scope="session">
<forward
name="success" path="/teqReport/reportSelect.jsp" />
</action>
</action-mappings>
===============================================================
14 years ago
Hey Eric,

Sorry for a lack of clarity. I need a drop down list to display 15 names in a scrolling format of the 170 possible Sales Rep. What I need is the following:

1. on form, without focus, size of window=1
2. multiple select
3. when selecting multiples, viewing the different choices in a drop-down the size of 15 names.

I apologize if I was not clear on this point. I am working under a deadline on a team project and have been asked to pick up the report function which includes the web presentation/parameter gathering. I earnestly have been trying to research code online that accomplishes the above things but all I seem to find are the two-tier examples. I may have found an example but my newness to javascipt may have prevented recogniztion.

Please accept my sincere thanks again for whatever help/direction/pointers you are willing to offer.

Take care and have a great day!

JD
I have to provide a html form element for a Sales Rep selection. Choices can be All, Single, or Multiple Selection. The form, due to constraints, can only show size=1. There are over 170 Sales Reps, so I need to control the size of the drop down but haven't seen code on how to do that? Also, I am basically confused on how to employ some of the javascript I have seen online.

Currently:
<SELECT name="select1" multiple size=1>
<OPTION>test1</OPTION>
<OPTION>test2</OPTION>
<OPTION>test3</OPTION>
<OPTION>test4</OPTION>
<OPTION>test5</OPTION>
<OPTION>test6</OPTION>
<OPTION>test7</OPTION>
<OPTION>test8</OPTION>
<OPTION>test9</OPTION>
<OPTION>test10</OPTION>
<OPTION>test11</OPTION>
<OPTION>test12</OPTION>
<OPTION>test13</OPTION>
<OPTION>test14</OPTION>
<OPTION>test15</OPTION>
<OPTION>test16</OPTION>
</SELECT>

Can someone provide suggestions and/or point me to a more illuminating example online? I may have some followup questions as I have not used javascript much before.

Thanks tons in advance!

JD
Thanks, I will do a quick study on double buffering to an image.

In terms of approach, I have a question. For the ovals representing the seven players, the image representing the ball, and the field lines layout, do I paint each of these under the extended JPanel class with the paintComponent? Or do I create a separate Object class representing Player, Ball, and Field? I am a bit confused on how to approach at this point? I am guessing that for the field layout I establish that as the background image for the panel.

As usual, eager to hear your reply!

Take care!

JD
14 years ago