I work on Java/HTML project. I've set a hashmap as a session attribute. I request the hashmap from session and put key/value in it
map.put("some string", "1")
. When this action is performed the second time, I print the hashmap content and the only value, that was '1' after the last operation on the hashmap, becomes '-1'.
Hashmap is the best data structure, in my opinion, for this project. Can anyone help?
public class Cart {
private HashMap<String, asd> list;
public Cart(){
list = new HashMap<String, asd>();
}
public HashMap<String, asd> getMap(){
return list;
}
/*
* Parameter: code
* -1: increase quantity by 1
* 0: delete product from the product list
* else: set the product quantity to the passed value
*/
public void alterProduct(int code, String product){
if(list.containsKey(product)) {
if(code == -1) plusOne(product);
if(code == 0) remove(product);
else setValue(product, code);
}else {
asd asd = new asd();
asd.a = 1;
list.put(product, asd);
}
}
private void plusOne(String product){
asd asd = list.get(product);
asd.a = asd.a + 1;
list.put(product, asd);
}
private void remove(String product){
list.remove(product);
}
private void setValue(String product, int code){
asd asd = new asd();
asd.a = code;
list.put(product, asd);
}
}
class asd{
int a;
public String toString(){
return ""+a;
}
}
JSP code where I set Cart object as session attribute:
<%
Cart myCart = new Cart();
session.setAttribute("cart",myCart);
%>
Servlet code:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
Cart cart = (Cart) request.getSession().getAttribute("cart");
cart.alterProduct(-1, (String) request.getSession().getAttribute("name"));
doGet(request, response);
}
After I call alterProduct the second time for the same (String) request.getSession().getAttribute("name") the hashmap value for the same key is '-1'.
What is type/value of product? How it is connected to the "cart"?
I guess what's happen that you mess up data types. Another option is you have bug in the Cart.toString() method. I suggest you change the code with "plain" data type and recheck it. If it fails, use your Cart class without messy conversion and debug the code.
You have bug here:
public void alterProduct(int code, String product){
if(list.containsKey(product)) {
if(code == -1) plusOne(product);
if(code == 0) remove(product);
else setValue(product, code);
}
private void setValue(String product, int code){
asd asd = new asd();
asd.a = code;
list.put(product, asd);
}
Consider what happen when you call art.alterProduct(-1, "something") second time.
list.containsKey(product) is true (you use the same product"), code is -1. So
if(code == -1) plusOne(product); is executed as expected.
But then you have something weired
if(code == 0) remove(product);
else setValue(product, code);
code ==0 is evaluated to false, so else instruction is called. You are calling setValue(product, -1)
As you can see above setValue will assign -1 to the asd.a that is observed by you.
Related
I am reading values from .xlsx using spring batch excel and POI. I see numeric values are printing with different format than the original value in .xlsx
Please suggest me , How to print the values as its in .xlsx file. Below are the details.
In my Excel values are as follows
The values are printing as below
My code is as below
public ItemReader<DataObject> fileItemReader(InputStream inputStream){
PoiItemReader<DataObject> reader = new PoiItemReader<DataObject>();
reader.setLinesToSkip(1);
reader.setResource(new InputStreamResource(DataObject));
reader.setRowMapper(excelRowMapper());
reader.open(new ExecutionContext());
return reader;
}
private RowMapper<DataObject> excelRowMapper() {
return new MyRowMapper();
}
public class MyRowMapper implements RowMapper<DataObject> {
#Override
public DataRecord mapRow(RowSet rowSet) throws Exception {
DataObject dataObj = new DataObject();
dataObj.setFieldOne(rowSet.getColumnValue(0));
dataObj.setFieldTwo(rowSet.getColumnValue(1));
dataObj.setFieldThree(rowSet.getColumnValue(2));
dataObj.setFieldFour(rowSet.getColumnValue(3));
return dataObj;
}
}
I had this same problem, and its root is the class org.springframework.batch.item.excel.poi.PoiSheet inside PoiItemReader.
The problem happens in the method public String[] getRow(final int rowNumber) where it gets a org.apache.poi.ss.usermodel.Row object and convert it to an array of Strings after detecting the type of each column in the row. In this method, we have the code:
switch (cellType) {
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
cells.add(String.valueOf(date.getTime()));
} else {
cells.add(String.valueOf(cell.getNumericCellValue()));
}
break;
case BOOLEAN:
cells.add(String.valueOf(cell.getBooleanCellValue()));
break;
case STRING:
case BLANK:
cells.add(cell.getStringCellValue());
break;
case ERROR:
cells.add(FormulaError.forInt(cell.getErrorCellValue()).getString());
break;
default:
throw new IllegalArgumentException("Cannot handle cells of type '" + cell.getCellTypeEnum() + "'");
}
In which the treatment for a cell identified as NUMERIC is cells.add(String.valueOf(cell.getNumericCellValue())). In this line, the cell value is converted to double (cell.getNumericCellValue()) and this double is converted to String (String.valueOf()). The problem happens in the String.valueOf() method, that will generate scientific notation if the number is too big (>=10000000) or too small(<0.001) and will put the ".0" on integer values.
As an alternative to the line cells.add(String.valueOf(cell.getNumericCellValue())), you could use
DataFormatter formatter = new DataFormatter();
cells.add(formatter.formatCellValue(cell));
that will return to you the exact values of the cells as a String. However, this also mean that your decimal numbers will be locale dependent (you'll receive the string "2.5" from a document saved on an Excel configured for UK or India and the string "2,5" from France or Brazil).
To avoid this dependency, we can use the solution presented on https://stackoverflow.com/a/25307973/9184574:
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
df.setMaximumFractionDigits(340);
cells.add(df.format(cell.getNumericCellValue()));
That will convert the cell to double and than format it to the English pattern without scientific notation or adding ".0" to integers.
My implementation of the CustomPoiSheet (small adaptation on original PoiSheet) was:
class CustomPoiSheet implements Sheet {
protected final org.apache.poi.ss.usermodel.Sheet delegate;
private final int numberOfRows;
private final String name;
private FormulaEvaluator evaluator;
/**
* Constructor which takes the delegate sheet.
*
* #param delegate the apache POI sheet
*/
CustomPoiSheet(final org.apache.poi.ss.usermodel.Sheet delegate) {
super();
this.delegate = delegate;
this.numberOfRows = this.delegate.getLastRowNum() + 1;
this.name=this.delegate.getSheetName();
}
/**
* {#inheritDoc}
*/
#Override
public int getNumberOfRows() {
return this.numberOfRows;
}
/**
* {#inheritDoc}
*/
#Override
public String getName() {
return this.name;
}
/**
* {#inheritDoc}
*/
#Override
public String[] getRow(final int rowNumber) {
final Row row = this.delegate.getRow(rowNumber);
if (row == null) {
return null;
}
final List<String> cells = new LinkedList<>();
final int numberOfColumns = row.getLastCellNum();
for (int i = 0; i < numberOfColumns; i++) {
Cell cell = row.getCell(i);
CellType cellType = cell.getCellType();
if (cellType == CellType.FORMULA) {
FormulaEvaluator evaluator = getFormulaEvaluator();
if (evaluator == null) {
cells.add(cell.getCellFormula());
} else {
cellType = evaluator.evaluateFormulaCell(cell);
}
}
switch (cellType) {
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
cells.add(String.valueOf(date.getTime()));
} else {
// Returns numeric value the closer possible to it's value and shown string, only formatting to english format
// It will result in an integer string (without decimal places) if the value is a integer, and will result
// on the double string without trailing zeros. It also suppress scientific notation
// Regards to https://stackoverflow.com/a/25307973/9184574
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
df.setMaximumFractionDigits(340);
cells.add(df.format(cell.getNumericCellValue()));
//DataFormatter formatter = new DataFormatter();
//cells.add(formatter.formatCellValue(cell));
//cells.add(String.valueOf(cell.getNumericCellValue()));
}
break;
case BOOLEAN:
cells.add(String.valueOf(cell.getBooleanCellValue()));
break;
case STRING:
case BLANK:
cells.add(cell.getStringCellValue());
break;
case ERROR:
cells.add(FormulaError.forInt(cell.getErrorCellValue()).getString());
break;
default:
throw new IllegalArgumentException("Cannot handle cells of type '" + cell.getCellTypeEnum() + "'");
}
}
return cells.toArray(new String[0]);
}
private FormulaEvaluator getFormulaEvaluator() {
if (this.evaluator == null) {
this.evaluator = delegate.getWorkbook().getCreationHelper().createFormulaEvaluator();
}
return this.evaluator;
}
}
And my implementation of CustomPoiItemReader (small adaptation on original PoiItemReader) calling CustomPoiSheet:
public class CustomPoiItemReader<T> extends AbstractExcelItemReader<T> {
private Workbook workbook;
#Override
protected Sheet getSheet(final int sheet) {
return new CustomPoiSheet(this.workbook.getSheetAt(sheet));
}
public CustomPoiItemReader(){
super();
}
#Override
protected int getNumberOfSheets() {
return this.workbook.getNumberOfSheets();
}
#Override
protected void doClose() throws Exception {
super.doClose();
if (this.workbook != null) {
this.workbook.close();
}
this.workbook=null;
}
/**
* Open the underlying file using the {#code WorkbookFactory}. We keep track of the used {#code InputStream} so that
* it can be closed cleanly on the end of reading the file. This to be able to release the resources used by
* Apache POI.
*
* #param inputStream the {#code InputStream} pointing to the Excel file.
* #throws Exception is thrown for any errors.
*/
#Override
protected void openExcelFile(final InputStream inputStream) throws Exception {
this.workbook = WorkbookFactory.create(inputStream);
this.workbook.setMissingCellPolicy(Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
}
}
just change your code like this while reading data from excel.
dataObj.setField(Float.valueOf(rowSet.getColumnValue(idx)).intValue();
this is only working for Column A,B,C
Hi I am new to spring MVC and am trying to implement a form:checkboxes tag and have run into a few issues. All the examples I have googled work with Strings and i want to work with objects so am hoping someone can advise.
I have a List of objects set in my DTO as follows:
TestDTO
private List<Barrier> barriers;
public List<Barrier> getBarriers() {
return barriers;
}
public void setBarriers(List<Barrier> barriers) {
this.barriers = barriers;
}
in my controller class I fetch the barrier objects from the database and add them to my DTO which will be passed to the jsp
savedRecord.setBarriers(dataService.getBarriers());
mav.addObject("testDto", savedRecord);
in my JSP I use the form:checkboxes tag as follows:
<form:checkboxes path="barriers" items="${testDto.barriers}" element="label class='block-label'"
itemLabel="barrier"/>
I also tried with adding
itemValue="id"
but that did not work either
this is wraped in a from element
<form:form method="post" accept-charset="UTF-8" action="${action}"
onsubmit="return checkAndSend()" id="create"
novalidate="" modelAttribute="testDto">
So the issues I am having are as follows:
The checkboxes when displayed all seem to be checked. I have implemented a hashcode and equals method on the barrier object but they still all seem to be checked when I want them unchecked.
Barrier.java
#Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((barrier == null) ? 0 : barrier.hashCode());
result = prime * result + ((display == null) ? 0 : display.hashCode());
result = prime * result + id;
return result;
}
#Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Barrier other = (Barrier) obj;
if (barrier == null) {
if (other.barrier != null)
return false;
} else if (!barrier.equals(other.barrier))
return false;
if (display == null) {
if (other.display != null)
return false;
} else if (!display.equals(other.display))
return false;
if (id != other.id)
return false;
return true;
}
When I click submit and i look at the testDto my barriers object list is null. How do I get the checked boxes that represent objects to be set on my testDto.
Any pointers and advice is appreciated
Thanks
UPDATE:
Thanks for the pointers. I went with the following. your suggestion helped.
I created the folloiwng in my controller
#InitBinder
public void initBinder(WebDataBinder binder)
{
binder.registerCustomEditor(Barrier.class, new BarrierPropertyEditor(barrierService));
}
and then added a class to do the conversion
public class BarrierPropertyEditor extends PropertyEditorSupport {
private BarrierService barrierService;
public BarrierPropertyEditor(BarrierService barrierService) {
this.barrierService = barrierService;
}
#Override
public void setAsText(String text) {
Barrier b = barrierService.findById(Integer.valueOf(text));
setValue(b);
}
}
This sets the barrier objects on my DTO.
(Sorry for the caps) IT DOES NOT SOLVE WHY THE CHECKBOXES ARE CHECKED ON INITIAL LOAD.
Any ideas how to set the checkboxes unchecked on intitial load?
You can use #ModelAttribute in your Controller to provide the list of values in checkboxes.
#ModelAttribute("barrierList")
public List<Barrier> populateBarrierList() {
List<Barrier> barrierList = dataService.getBarriers();
for(Barrier barrier: barrierList )
{
barrierList.add(barrier);
}
return barrierList ;
}
In JSP, use following :
<form:checkboxes path="barriers" items="${barrierList}" element="label class='block-label'" itemLabel="barrier"/>
I want to add some attributes to the model, but for some reason, one of the attributes isn't being added to the model for a specific request handler.
The two attributes are numberDeleted and usersDeleted.
usersDeleted for some reason is not added to the model on the third request handler.
Here is the code: (Note: Some lines of code has been removed for brevity. Only the relevant code is displayed).
First I delete some selected users:
#RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public String delete(
#ModelAttribute("credentials") Credentials credentials,
#ModelAttribute("deleteUsersForm") DeleteUsersForm form,
#ModelAttribute("searchCriteria") SearchForm searchForm,
Model model, RedirectAttributes redirect) {
String[] usersDeleted = form.getCheckedUsers();
if (usersDeleted != null) {
for (int i = 0; i < usersDeleted.length; i++) {
System.out.println("user (delete): " + usersDeleted[i]);
}
}
redirect.addFlashAttribute("usersDeleted", usersDeleted);
redirect.addFlashAttribute("numberDeleted", numberDeleted);
redirect.addFlashAttribute("searchForm", searchForm);
return "redirect:" + searchForm.getSelectedOption();
}
After the chosen users are deleted from the database, I make a REST API call to get the currently existing users and add them to the model, as well as the numberDeleted and usersDeleted from the delete function above:
#RequestMapping(value = "/getAllUsers", method = RequestMethod.GET)
public String getAllUsers(#ModelAttribute Credentials credentials,
RedirectAttributes redirect, Model model) {
SearchForm searchForm = new SearchForm("/getAllUsers", "allUsers");
redirect.addFlashAttribute("users", users);
redirect.addFlashAttribute("searchCriteria", searchForm);
/* If users deleted: */
Integer numberDeleted = (Integer) model.asMap().get("numberDeleted");
String[] usersDeleted = (String[]) model.asMap().get("usersDeleted");
redirect.addFlashAttribute("numberDeleted", numberDeleted);
redirect.addFlashAttribute("usersDeleted,", usersDeleted);
if (usersDeleted != null) {
for (int i = 0; i < usersDeleted.length; i++) {
System.out.println("user: (getAllUsers) " + usersDeleted[i]);
}
}
return "redirect:/adminHome";
}
The usersDeleted and numberDeleted are not null up to this point and I can print out their value.
Then I call the request to list the users:
#RequestMapping(value = "/adminHome", method = RequestMethod.GET)
public String getAdminHomePage(Model model) {
SearchForm searchCriteria = (SearchForm) model.asMap().get(
"searchCriteria");
/* If users were deleted: */
Integer numberDeleted = (Integer) model.asMap().get("numberDeleted");
String[] usersDeleted = (String[]) model.asMap().get("usersDeleted");
model.addAttribute("numberDeleted", numberDeleted);
model.addAttribute("usersDeleted,", usersDeleted);
if (usersDeleted != null) {
for (int i = 0; i < usersDeleted.length; i++) {
System.out.println("user: (adminhome) " + usersDeleted[i]);
}
}
.....
return "admin_home";
}
However, at this point, usersDeleted is null (since nothing prints out) but numberDeleted is not null.
I literally do not understand what is going on. How come it is null? I explicitly added it to the model.
EDIT 1:
Currently, my only workaround is to add usersDeleted to #SessionAttributes.
But I should not have to resort to this.
As per #Kingamere comments, I am posting this. There was a typo on the model key.
model.addAttribute("usersDeleted,", usersDeleted);
There was an extra comma at the end of the usersDeleted. After you remove that comma, it works perfectly for Kingmere.
model.addAttribute("usersDeleted", usersDeleted);
I'm pretty sure that I have to use Collections, but I'm honestly super lost on how to implement it! My assignment needs me to
"Allow the user to view the plants sorted by price (lowest to highest), scientific name (alphabetized by genus), or common name (alphabetized by first letter of first word)."
this is my code, I don't know where to exactly put the sorting and how to write it in code :(
package plant.nursery.program;
import java.util.Scanner;
import java.util.ArrayList;
public class PlantNurseryProgram {
private double maxHeightInFt;
private String commonName;
private String scientificName;
private double price;
boolean isFragile;
public PlantNurseryProgram(String commonName,
String scientificName, double maxHeightInFt, double price,
boolean isFragile) {
this.maxHeightInFt = maxHeightInFt;
this.commonName = commonName;
this.scientificName = scientificName;
this.price = price;
this.isFragile = isFragile;
}
#Override
public String toString() {
return commonName + " (" + scientificName + ") " + "is " +
maxHeightInFt + " ft tall " + "it costs $" + price + " and "
+ "isFragile = " + isFragile;
}
public String setName(String newName){
commonName = newName;
return newName;
}
public String setSName(String newSName)
{
scientificName = newSName;
return scientificName;
}
public double setHeight(double newHeight){
maxHeightInFt = newHeight;
return maxHeightInFt;
}
public double setPrice(double newPrice){
price = newPrice;
return price;
}
public boolean setFragile(boolean newFragile){
isFragile = newFragile;
return isFragile;
}
public static void main(String[] args) {
Scanner plant = new Scanner(System.in);
boolean toContinue = true;
ArrayList<PlantNurseryProgram> plantNurseryAL = new ArrayList<>();
do
{
System.out.println("What's the name of your plant");
String commonName = plant.next();
System.out.println("What's the scientific name for your plant?");
String scientificName = plant.next();
System.out.println("How tall is your plant?");
double maxHeightInFt = plant.nextDouble();
System.out.println("What's the price of your plant?");
double price = plant.nextDouble();
System.out.println("Is the plant fragile? If yes type(true), if no "
+ "type (false)");
boolean isFragile = plant.nextBoolean();
System.out.println("Do you wish to continue?");
toContinue = plant.nextBoolean();
PlantNurseryProgram userPlant = new PlantNurseryProgram(
commonName, scientificName, maxHeightInFt, price, isFragile);
plantNurseryAL.add(userPlant);
System.out.println("Is all the information you entered correct?");
boolean corrections = plant.nextBoolean();
if(corrections == false)
{
System.out.println("What would you like to correct?"
+ " 1. Name, 2. Scientific name, 3. Height, 4. Price"
+ "5. Fragility?" );
int userChoice = plant.nextInt();
if(userChoice == 1)
{
System.out.println("Please enter the correct name");
String newName = plant.next();
userPlant.setName(newName);
System.out.println(userPlant);
}
else if(userChoice == 2)
{
System.out.println("Please enter the correct scientific name");
String newSName = plant.next();
userPlant.setSName(newSName);
System.out.println(userPlant);
}
else if(userChoice == 3)
{
System.out.println("Please enter the correct height");
double newHeight = plant.nextDouble();
userPlant.setHeight(newHeight);
System.out.println(userPlant);
}
else if(userChoice == 4)
{
System.out.println("Please enter the correct price");
double newPrice = plant.nextDouble();
userPlant.setPrice(newPrice);
System.out.println(userPlant);
}
else if(userChoice == 5)
{
System.out.println("Please enter if the plant is fragile or not");
boolean newFragile = plant.nextBoolean();
userPlant.setFragile(newFragile);
System.out.println(userPlant);
}
}
} while(toContinue == true);
for (PlantNurseryProgram plantNurseryProgram : plantNurseryAL) {
System.out.println(plantNurseryProgram);
} // end of for loop
} //end of main
} // end of class
You're posting too much here. To figure out what to do, you don't need a main method or a user interface. By the way, conventionally, setters are void methods.
You should become familiar with the available methods for collections in the java.util package. Or you can use the index and look up sort. You will see that the Collections class has two sort methods. One is for the case when the class is inherently Comparable:
public class TemperatureGauge implements Comparable<TemperatureGauge> {...}
The other is when a class may be sorted many different ways, so that there is no natural way to define a standard comparison. Then, you create a Comparator.
public class CommonNameComparator implements Comparator<PlantNurseryProgram> {
public int compare(PlantNurseryProgram left, PlantNurseryProgram right) {
// Do something with left.getCommonName() and right.getCommonName().
// It must return a negative, zero, or positive depending on whether
// left should come before, in the same place, or after right.
return /*anInteger*/;
}
}
Repeat the process for the scientific name and the price.
For extra credit, write JUnit tests for each comparator and for the sorting process.
You can use set interface of collection class.Before that first you should override the equals and hashcode method in your code with the field according to which you want to short.
After this you can create object of PlantNurseryProgram and this in one of the subclass of set interface.As per your requirement you can use Treeset class.
Reemember there are several other ways to ddo this.Using set you can not duplicate item.
If your purpose is to sort after inserting the data in data structure the use sort method provided in java collection api.
See the below link.
http://www.roseindia.net/java/jdk6/set-interface.shtml
I've got an issue with SortableDataProvider and DataTable in wicket.
I've defined my DataTable as such:
IColumn<Column>[] columns = new IColumn[9];
//column values are mapped to the private attributes listed in ColumnImpl.java
columns[0] = new PropertyColumn<Column>(new Model<String>("#"), "columnPosition", "columnPosition");
columns[1] = new PropertyColumn<Column>(new Model<String>("Description"), "description");
columns[2] = new PropertyColumn<Column>(new Model<String>("Type"), "dataType", "dataType");
Adding it to the table:
DataTable<Column> dataTable = new DataTable<Column>("columnsTable", columns, provider, maxRowsPerPage) {
#Override
protected Item<Column> newRowItem(String id, int index, IModel<Column> model) {
return new OddEvenItem<Column>(id, index, model);
}
};
My data provider:
public class ColumnSortableDataProvider extends SortableDataProvider<Column> {
private static final long serialVersionUID = 1L;
private List<Column> list = null;
public ColumnSortableDataProvider(Table table, String sortProperty) {
this.list = Arrays.asList(table.getColumns().toArray(new Column[0]));
setSort(sortProperty, true);
}
public ColumnSortableDataProvider(List<Column> list, String sortProperty) {
this.list = list;
setSort(sortProperty, true);
}
#Override
public Iterator<? extends Column> iterator(int first, int count) {
/*
first - first row of data
count - minimum number of elements to retrieve
So this method returns an iterator capable of iterating over {first, first+count} items
*/
Iterator<Column> iterator = null;
try {
if(getSort() != null) {
Collections.sort(list, new Comparator<Column>() {
private static final long serialVersionUID = 1L;
#Override
public int compare(Column c1, Column c2) {
int result=1;
PropertyModel<Comparable> model1= new PropertyModel<Comparable>(c1, getSort().getProperty());
PropertyModel<Comparable> model2= new PropertyModel<Comparable>(c2, getSort().getProperty());
if(model1.getObject() == null && model2.getObject() == null)
result = 0;
else if(model1.getObject() == null)
result = 1;
else if(model2.getObject() == null)
result = -1;
else
result = ((Comparable)model1.getObject()).compareTo(model2.getObject());
result = getSort().isAscending() ? result : -result;
return result;
}
});
}
if (list.size() > (first+count))
iterator = list.subList(first, first+count).iterator();
else
iterator = list.iterator();
}
catch (Exception e) {
e.printStackTrace();
}
return iterator;
}
The problem is the following:
- I click a column header to sort by that column.
- I navigate to a different page
- I click Back (or Forward if I do the opposite scenario)
- Page has expired.
It'd be nice to generate the page using PageParameters but I somehow need to intercept the sort event to do so.
Any pointers would be greatly appreciated. Thanks a ton!!
I don't know at a quick glance what might be causing this, but in order to help diagnose, you might want to enable debug logging for org.apache.wicket.Session or possibly more of the wicket code.
The retrieval of a page definitely involves calls to a method
public final Page getPage(final String pageMapName, final String path, final int versionNumber)
in this class, and it has some debug logging.
For help with setting up this logging, have a look at How to initialize log4j properly? or at the docs for log4j.