This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

howard franklin

Greenhorn
+ Follow
since Sep 09, 2012
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 howard franklin

I am new to struts and I am trying to learn logic:interate.

I am trying make changes to the following code.


<logic:iterate name="testDateStrList" id="testDate">
<p>
List Messages <bean:write name="testDate"/>
</p>
</logic:iterate>


I created this on my action

String myDate = "01/01/2013";
request.setAttribute("myDate",myDate);


on my jsp I want to test the arraylist value with my object.
I know that the logic:iterate works with an arraylist. However can
it work with an object to perform a comparison?


<logic:iterate name="testDateStrList" id="testDate">
<p>
List Messages <bean:write name="testDate"/>
</p>

<C:if test="${testDate == myDate}">
<h2>hey the daate is <c:out value="${testDate}"/></h2>
</C:if>
</logic:iterate>

In this example it passes the if statement no matter what.

My results.... Not sure what the if statement is comparing.
This (testDate == myDate) should be 2 string . I am not sure


List Messages 01/10/2013

hey the daate is 01/10/2013
List Messages 07/01/2013

hey the daate is 07/01/2013
List Messages 06/18/2013

hey the daate is 06/18/2013
List Messages 01/01/2013

hey the daate is 01/01/2013
List Messages 06/19/2013

hey the daate is 06/19/2013


8 years ago
I posted it to soon.. I added the following and it worked..

for (int i = 0; i < collection.size(); i++){

// Date test = collection.get(i);
System.out.println("Item " + i + " : " + collection.get(i) );
System.out.println("You were arrested on : " + collection.get(i).getArressDate());
System.out.println("Your offense was on : " + collection.get(i).getOffenseDate());

}

// for(String item: stringList){
// System.out.println("retrieved element: " + item);
}
8 years ago
I am trying to learn how to print out an array of objects;
I can print the collection such as the followign.

MyTest.arrestDateStrList2@140c281
MyTest.arrestDateStrList2@a1d1f4
MyTest.arrestDateStrList2@1df280b

How do I print out the items in each.
arrestdate: Thu Jan 07 00:00:00 PST 1999
offensedate: Sun Feb 07 00:00:00 PST 1999
arrestdate: Sun Mar 07 00:00:00 PST 1999
offensedate: Wed Apr 07 00:00:00 PDT 1999


arrestDateStrList2.java

import java.util.Date;
public class arrestDateStrList2 {
private Date arrestDate;
private Date offenseDate;

public arrestDateStrList2(Date arrestDate, Date offenseDate) {
this.arrestDate = arrestDate;
this.offenseDate = offenseDate;
}

public Date getArressDate() { return arrestDate; }
public Date getOffenseDate() { return offenseDate; }
}

myArrayList.java

package MyTest;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

public class myArrayLists {
public static void main(String [] args) {
Date newDate = new Date(99,0,7);
Date newDate2 = new Date(99,1,7);
Date newDate3 = new Date(99,2,7);
Date newDate4 = new Date(99,3,7);
Date newDate5 = new Date(99,2,7);
Date newDate6 = new Date(99,3,7);

System.out.println(" date: " + newDate);
System.out.println(" date2: " + newDate2);
System.out.println(" date3: " + newDate3);
System.out.println(" date4: " + newDate4);


ArrayList<arrestDateStrList2> collection = new ArrayList<arrestDateStrList2>();
arrestDateStrList2 yeah = new arrestDateStrList2(newDate,newDate2);
collection.add(yeah);

// size() tells me how many slots are in the list
System.out.println("number of slots: " + collection.size());

arrestDateStrList2 sesameSt = new arrestDateStrList2(newDate3,newDate4);
collection.add(sesameSt);
// size() tells me how many slots are in the list
System.out.println("number of slots: " + collection.size());

arrestDateStrList2 third = new arrestDateStrList2(newDate5,newDate6);
collection.add(third);
// size() tells me how many slots are in the list
System.out.println("number of slots: " + collection.size());

System.out.println("now using iterator");
Iterator itr = collection.iterator();

//use hasNext() and next() methods of Iterator to iterate through the elements
System.out.println("Iterating through ArrayList elements...");
while(itr.hasNext())
System.out.println(itr.next());

}
}

Howard
8 years ago
I created a new base layout page called createdby_layoutIa.jsp

I created the definition to define it

<definition name="createdby.layoutIa" path="/createdby_layoutIa.jsp">
<put name="title" value=""/>
<put name="body" value=""/>
</definition>

I create another definition that extends it.
<definition name="intake.assignment.summary" extends="createdby.layoutIa">
<put name="title" value="Intake Assignment Summary"/>
<put name="body" value="/WEB-INF/intake/intake_assignmentsummary.jsp"/>
<put name="displayheader" value="false"/>
</definition>
It works but the page createdby_layoutIa.jsp has a small blue question mark by it in the project explorer.
Does anyone know what this question mark means?
8 years ago
I built a link using

<a href='int/readI.do?inta=<bean:write name="inta" property="id"/>'>

Once rendered it filled in the http://www.domain.com/

displaying http://www.domain.com/int/readI.do?inta=123456

-------------------------------------------------------------------

I built another link where I passed in information to a function.

function used


html calling function

<a href="javascript:setSId('484919','N/A','int/readI.do?intid=1340387')"/>P388</a>

However when it throughs this link using document.location.href the link is missing

html://www.domain.com/

I know this because I contactenated that part and it worked.

What do I need to do to use document.location.href in order for it prefix in the domain.

Or is there another way I can call a function and after the function has run fire off the link

I am looking at some code that I think is using a lov control. Can anyone point me to an lov control tutorial.

<ms:lov
id="iClerk"
image="images/btnBrowse.gif"
beanName="com.RoleFacility"
properties="username,firstName,lastName,facilityName"
headers="TO Identifier,First Name, Last Name, Area Office"
columns="username,firstName,lastName,facilityName"
form="IEditForm"
fields="dStr"
returns="username"
width="800"
height="600">
<ms:lovFilter property="dId" value="0" operator="gt"/>
<ms:lovFilter property="subRoleCode" value="IpO,ISPO" operator="in"/>
</ms:lov>
9 years ago
This page is submitted using button that calls a function that submits the page using the dom.
After it sets a function/parameter


document.forms['I'].elements['function'].value = 'addOffice';
document.forms['I'].submit();


This sends it to the action addOffice.

My question is about the saveToken.

I understand that saveToken() - generate the token key and save to request/session attribute.

My problem is that I am debugging this and I see that it does not get pass the SaveToken(request) statement and then
my page refreshes. Is there something that I am missing here?

I appreciate any help




resetParentStatement(request, frm);
setRequestAttributes (request, frm, null, true);
saveToken (request);

//return mapping.getInputForward ();
ActionForward testActionForward = mapping.getInputForward();
StringBuffer path = new StringBuffer (testActionForward.getPath());
path.append("?#arrest");
ActionForward myNewActionForward = new ActionForward(path.toString());
myNewActionForward.setRedirect (true);
return myNewActionForward;

Howard
9 years ago
I was able to figure it out

info from struts config










9 years ago
Can not figure this out.. I keep getting the following error.

[ServletException in:/SelectListTest.jsp] javax.servlet.jsp.JspException: Cannot find bean streetlist in any scope'

At the moment my action is called. (com.info.SelectListAction) I would think that this is populated.

Is there anything else that I should be looking at. Was able to make the example work. I am trying to incorporate what I did there
and I am not having any success.


struts-config.xml





SelectListTest.jsp




SelectListAction.java




StreetListData.java



SelectForm

9 years ago
Question about the Following code.

I understand that this is use to get the connection from Struts DataSource:

dataSource = getDataSource(request);
myConnection = dataSource.getConnection();

My confusion is what does request stand for.
9 years ago
Do you guys understand the parameter=”function”?

Is the function being being pass to IntakeClerkAction?
Or is it being passed to the forward action?

<action path="/intakeclerk"
type="com.capita.pcms.web.struts.intake.IntakeClerkAction"
name="IntakeEditForm"
validate="false"
input="/intakeMinorForm.do"
scope="request"
parameter="function">

<forward name="editTake" redirect="true" path="/intakeclerk.do?function=editIntake"/>
<forward name="error" path="/intakeHistory.do?function=getInt"/>
<forward name="invalidaddress" path="/intakeclerk.do?function=editIntake&intakeid=-1"/>
</action>

9 years ago
Thank you. That did it. I really appreciate your help

Howard
I thought my problem had to do with the current_session_context_class.

I change from
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
to
<property name="current_session_context_class">thread</property>

but I am still having problems. Looking at the console looks like I got through everything
except for the current_session_context_class and the mapping.