File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes values are not populated in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "values are not populated in browser" Watch "values are not populated in browser" New topic

values are not populated in browser

vedha lambu

Joined: Mar 13, 2011
Posts: 3
Hi All,

I developed one application using struts2+Jpgrid(json)+Hibernate.I cann't able to send the values from server to browser.I debugging using firebox ,i am getting following values in server side.

MY JSP----------->
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<title>jqGrid Demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.7.1.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">


datatype: "json",
mtype: 'POST',
colNames:['Id','firstName', 'lastName','cellNo'],
colModel :[
{name:'id', index:'id', width:80},
{name:'firstName', index:'firstName', width:200},
{name:'lastName', index:'lastName', width:200, align:'right'},
// {name:'emailId', index:'email_Id', width:200, align:'right'},
{name:'cellNo', index:'cell_No', width:200, align:'right'}
pager: jQuery('#pager2'),
sortname: 'id',
sortorder: "desc",
viewrecords: true,
caption: 'My first grid'


<div id="pager2" class="scroll" ></div>




import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import net.sf.json.JSONObject;

import com.opensymphony.xwork2.ActionSupport;

public class ContactAction extends ActionSupport {
static final Logger logger = Logger.getLogger(ContactAction.class);

private static final long serialVersionUID = 9149826260758390091L;
private Contact contact;
private List<Contact> contactList;
//private int id;
//Get the requested page. By default grid sets this to 1.
private Integer page = 0;
// sorting order - asc or desc
private String sord;
// get index row - i.e. user click to sort.
private String sidx;
private Integer rows = 0;
// Your Total Pages
private Integer total = 0;
// All Record
private Integer records = 0;

private ContactManager linkController;

public ContactAction() {
linkController = new ContactManager();
public String execute() {
/*if(null != contact) {
logger.debug((new StringBuilder("Page ")).append(getPage()).append(" Rows ").append(getRows()).append(" Sorting Order ").append(getSord()).append(" Index Row :").append(getSidx()).toString());
contactList = linkController.list();
Map map = new HashMap ();
map.put ("page", page);
map.put ("total", total);
List mapList = new ArrayList ();
Map cellMap = new HashMap ();
for (Iterator iterator = contactList.iterator (); iterator.hasNext ();) {
cellMap.put ("id", contact.getId());
cellMap.put ("cell", new Object[] {contact.getId (),
mapList.add (cellMap);
map.put ("rows", mapList);

JSONObject object = new JSONObject();
System.out.println (object.toString ());
total = Integer.valueOf((int)Math.ceil((double)records.intValue() / (double)rows.intValue()));
return SUCCESS;

public List<Contact> getContactList() {
return contactList;
/*public void setContact(Contact contact) { = contact;

* @return the page
public Integer getPage() {
return page;
* @param page the page to set
public void setPage(Integer page) { = page;
* @return the sord
public String getSord() {
return sord;
* @param sord the sord to set
public void setSord(String sord) {
this.sord = sord;
* @return the sidx
public String getSidx() {
return sidx;
* @param sidx the sidx to set
public void setSidx(String sidx) {
this.sidx = sidx;
* @return the rows
public Integer getRows() {
return rows;
* @param rows the rows to set
public void setRows(Integer rows) {
this.rows = rows;
* @return the total
public Integer getTotal() {
return total;
* @param total the total to set
public void setTotal(Integer total) { = total;
* @return the records
public Integer getRecords() {
return records;
* @param records the records to set
public void setRecords(Integer records) {
this.records = records;
if(this.records.intValue() > 0 && rows.intValue() > 0)
total = Integer.valueOf((int)Math.ceil((double)this.records.intValue() / (double)rows.intValue()));
} else
total = Integer.valueOf(0);




<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources"
value="ApplicationResources" />

<package name="default" extends="struts-default" namespace="/">
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />


<interceptor name="mylogging"
<interceptor-stack name="loggingStack">
<interceptor-ref name="mylogging" />
<interceptor-ref name="defaultStack" />
<action name="login"
<interceptor-ref name="loggingStack"></interceptor-ref>
<result name="success" type="tiles">/tmu.tiles</result>
<result name="error">Login.jsp</result>
<action name="tmuAdmin"
class="" method="tabActions">
<interceptor-ref name="loggingStack"></interceptor-ref>
<result name="success" type="tiles">/tmuAdmin.tiles</result>
<result name="error">Login.jsp</result>
<action name="tmu"
class="" method="tabActions">
<interceptor-ref name="loggingStack"></interceptor-ref>
<result name="success" type="tiles">/tmu.tiles</result>
<result name="error">Login.jsp</result>

<action name="index"
<result name="success">/pages/index.jsp</result>

Kindly give solution for these one

Joe Ess

Joined: Oct 29, 2001
Posts: 9168

I asked you in your previous post to use CodeTags. Your post is practically unreadable. You should also make some effort at Isolating The Problem. The easier it is to read your code, the more help we can be.

[How To Ask Questions On JavaRanch]
vedha lambu

Joined: Mar 13, 2011
Posts: 3
Hi Joe Ess,

Thank you for replaying now its working fine.I have another problem suppose i will try to add new record for that purpose i click the add symbol in navigator bar after that open the new window in side of this pop-up contains default length field how to increase size of the fields(customized) length
Elena Colomo

Joined: Oct 25, 2011
Posts: 1
Hi Vedha,

how did you solve it? Do you use struts tags or you could solve it using javascript?

I have the same problem and I want to use javascript because I want to put images in some columns.

Thank you,

vedha lambu wrote:Hi Joe Ess,

Thank you for replaying now its working fine.I have another problem suppose i will try to add new record for that purpose i click the add symbol in navigator bar after that open the new window in side of this pop-up contains default length field how to increase size of the fields(customized) length
I agree. Here's the link:
subject: values are not populated in browser
It's not a secret anymore!