Skip to main content

Reading widget value in jsp/ servlet after post of the page

7 replies [Last post]
krishnag
Offline
Joined: 2008-02-12
Points: 0

Hello,

I am new to jMaki and I appreciate the concept of jMaki ( By hiding the details of underlying framework and gives impression that we are woking on only one AJAX Framework).....

I am integrating jMaki Ajax Libraries with my existing application so I did a sort of feasibility analysis.....
I faced the following problem....

I have trying one sample of AutoComplete in using jMaki's Yahoo Autocomplete....
How do i read the value of the AutoComplete textbox when submitted to the ./receiveInput.jsp

Sample code is like ------

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

JSP Page

JSP Page

I want to read the value selected by the user in receiveInput.jsp when form is submitted...

Any help is appreciated....

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rambomogambo
Offline
Joined: 2008-06-05
Points: 0

oh and for my environment .... I am using netbeans 6.1/6.5 on the dev box (widows), and web app gets deployed to glassfishV2u2 (linux/fedoracore6)

pl. let me know how i can get the value that was in the widget when the form is processed at the server side.

sloanb
Offline
Joined: 2003-09-14
Points: 0

What does the value of your bean DataBean.data look like? It should be in JSON Array format like the example below:

[code]
value="[
{label : 'Alabama', value : 'AL'},
{label : 'California', value : 'CA'},
{label : 'New York', value : 'NY', selected : true},
{label : 'Texas', value : 'TX'}
]"/>
[/code]

If you do not specify a label the value will be used by default. If you are wanting to make the lookup live you need to use the service attribute of the widget, which can be pointed to a jsp, Servlet, or JSF managed bean assuming you are using java. If you need further assistance with this let me know and I will provide an example.

As far as how you read the value from the widget I need to know a little bit more about how you are planning on submitting the form. There are several ways to do this including getting the widget by using jmaki.getWidget(widgetId) and getting the value by widget.getValue(). Let me know a little bit more about your environment and I will gladly assist you.

rambomogambo
Offline
Joined: 2008-06-05
Points: 0

Sloanb - I am not having any issues getting the data loaded into the widget. The page also renders and as I type the values ... the data is getting pulled nicely, live. So, that is not the issue.

My problem is I am submitting the form. A simple/regular jsp page that has an html form. When this form is submitted, it calls a jsp (actually it self in come cases), and I want to know the value that was populated in the widget.

Here is my code snippet from the jsp page ...

we are testing ajax ...

State:
City:
Zip:
bakarirum
Offline
Joined: 2005-07-07
Points: 0

So you are wanting the values in the widget to be submitted as request parameters. I am sure Sloan or anyone else could provide you with detail on how to do that.

However, you can capture the submit of the form (onsubmit="") and in your javascript read the values in the widget and load up "hidden" form fields in the form and then return true from the JavaScript method and it will post your variables that way.

rambomogambo
Offline
Joined: 2008-06-05
Points: 0

bakarium - Is see... I do call a javascript on submit ... primarily I do user data validation etc... there, and could do what you are suggesting. But, is there a better way to do this rather than loading up values from widget into hidden field?

I also have another related question ... my apologies that my code sample is not formatted correctly (the code format button in the menu is not showing up for me). But if you see in my code .. I am basically filling the state value dynamically, and likewise for the city. What I think would be neat is when the city value is pulled, it (citypicker.jsp) knows what state value is in the state widget - how would I do this?

Thanks

krishnag
Offline
Joined: 2008-02-12
Points: 0

JUST put into the correct formatting

Hello,

I am new to jMaki and I appreciate the concept of jMaki ( By hiding the details of underlying framework and gives impression that we are woking on only one AJAX Framework)..... I am integrating jMaki Ajax Libraries with my existing application so I did a sort of feasibility analysis.....
I faced the following problem....

I have trying one sample of AutoComplete in using jMaki's Yahoo Autocomplete.... [i]How do i read the value of the AutoComplete textbox when submitted to the [i]./receiveInput.jsp[/i][/i] Sample code is like ------

[b]code fragment[/b]




I want to read the value selected by the user in [i][b]receiveInput.jsp[/b][/i] when form is submitted... Any help is appreciated....

Thanks

rambomogambo
Offline
Joined: 2008-06-05
Points: 0

Has anyone been able to get the value that is filled in via an AJAX widget back when the form is submitted ... in the jsp/servlet or bean?

I am nowq dealing with the same issue krishnag has asked ... I am sure this is doable ... please help answer - anyone?