[ 5 posts ]

Gopinadh

  • Username: ugopi_15
  • Joined: Wed Feb 15, 2012 7:39 am
  • Posts: 6
  • Offline
  • Profile

How to read a variable from request in YUI-2?

Post Posted: Wed Feb 15, 2012 8:11 am
+0-
Can anyone tell me how to read a request variable in YUI-2?

Alberto Santini

YUI Contributor

  • Offline
  • Profile
Tags:

Re: How to read a variable from request in YUI-2?

Post Posted: Wed Feb 15, 2012 10:41 am
+0-
Hello Gopinadh.

What do you mean? Please provide a snippet to describe the issue.

If I understood correctly the question, you may give a look at the Connection Manager module and his examples:

http://developer.yahoo.com/yui/connection/

Hope that helps,
IceBox

Gopinadh

  • Username: ugopi_15
  • Joined: Wed Feb 15, 2012 7:39 am
  • Posts: 6
  • Offline
  • Profile

Re: How to read a variable from request in YUI-2?

Post Posted: Wed Feb 15, 2012 11:13 am
+0-
Hi,
I am setting a variable in request from my controller which i need to read in YUI-2 script. This is being set in my controller & is being forwarded to my JSP. I am using a datatable in my screen which has the datasource returning an XML. Is there a way i can put an attribute in request which can be read separately from YUI-2 script instead of just reading from it's datasource?

Below is the code from backend controller.
---------------------------------------------------------------
String xml = xstream.toXML(calendars);
getRequest().setAttribute("xmlbean", xml);

this.getRequest().setAttribute("currentPageForNavigation",
this.getFromSession("currentPageForNavigation");

Here is the snippet from my YUI-2 script
-----------------------------------------------------------
var myColumnHeaders = [
{text:"Actions",formatter:formatActionColumn,key:"oid"},
{text:"Plan",key:"planAcronym"},
{text:"Locked",key:"hasBillingSchedules",formatter:formatIsLockedColumn},
{text:"Client",key:"client"},
{text:"SubClient",key:"subClient"},
{text:"Name",key:"name"},
{text:"Type",key:"billingCalendarTypeKey"},
{text:"Frequency",key:"billingFrequency"},
{text:"RunOffSet Days",key:"runOffsetDays"},
{text:"BillingType",key:"billingClientTypeKey"},
{text:"ClientType",key:"clientType"},
{text:"RunOffsetCycleType",key:"runOffsetCycleTypeKey"}
];

var myColumnSet = new YAHOO.widget.ColumnSet(myColumnHeaders);

var myDataSource = new YAHOO.util.DataSource(getURI('loadAllBillingCalendar.do'));
myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
myDataSource.responseSchema = {
resultNode: 'cals',
id: 'oid',
fields: ['planAcronym', 'client' ,'subClient', 'name','billingCalendarTypeKey','runOffsetDays','billingFrequency', 'billingClientTypeKey','oid','hasBillingSchedules','clientType','runOffsetCycleTypeKey']
};

var defaultDataTable = new YAHOO.widget.DataTable("standardselect",myColumnSet,myDataSource,
{paginator:'true',rowsPerPage:10});
defaultDataTable.subscribe("cellClickEvent",defaultDataTable.onEventSelectRow);
defaultDataTable.select(defaultDataTable.getRow(0));


**********Right now, if you see at the last line, i am defaulting the table to select the first row. But, my table has pagination. So, when i reload the page, i need to read the previously visited page number from session & go back to that page.
So, I am trying to read the current page number & put it in session. While reloading the page, i am trying to set that page number in request to be read in my script to go back to the original visited page.

The other problem: How do i get handle to my datatable's page number? I am clicking one of the images in the row data in one of the cells.


Thanks for the help.

Gopinadh

  • Username: ugopi_15
  • Joined: Wed Feb 15, 2012 7:39 am
  • Posts: 6
  • Offline
  • Profile

Re: How to read a variable from request in YUI-2?

Post Posted: Thu Feb 16, 2012 6:55 am
+0-
Any clues?

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: How to read a variable from request in YUI-2?

Post Posted: Thu Feb 16, 2012 8:33 am
+0-
You should probably be using "metaFields" in your DataSource schema. You can load as many extra data items as you like in the meta. Look into http://developer.yahoo.com/yui/datasource/ and search down to the XML section.

I'm a little rusty at the exact call, but you can over-ride either handleResponse or one of the onDataReturnXXXXRows methods to extract the meta data and do what you want with it.
http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_onDataReturnAppendRows for example.

I don't know JSP, but you cannot send Objects via remote requests, so if you are sending an object you would need to stringify before send/parse upon receipt to convert it to an object.
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum