• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

i refresh after an onchange event on a combobox and i need the parameters in request

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic :
i have a combox, i choose an option and i need to show a different content in the same page , for any option
i tried with refresh (i thought to refresh the page when choosing a new option) and get the paramater in request or pageContext but i have NO cache when refresh in javascript , so the parameters are null:
<select name=optionField onchange="refresh()">
<option value="noChoice">...
<option value="user">User
<option value="group">Group
<option value="number">Number
</select>
<script type="text/javascript">
function refresh()
{
window.location.reload( false );
}
</script>
<%
out.println(request.getParameter("optionField"));
out.println(request.getAttribute("optionField"));
out.println(pageContext.getAttribute("optionField"));
// all the outs are ever null
%>
some suggestions , or a different solution ( the combo it's a must, anyway )
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not quite sure what you are trying to accomplish. Why do you need to 'refresh' the page after the dropdown changes?
Is it to fetch new data from the server to display in another drop-down (or other controls on the page)?
If so, then the window.location.reload() method isn't going to do anything for you. All it will do is to reload the same page (from cache if it can, since you specified false as the parameter).
To cause a server hit that can actually perform actions (such as fetching data from the server to show elsewhere on the page) you are going to have to submit the current page to a servlet (or other server-side mechanism) that can do the data lookup for you.
Since the form values will be submitted as part of this request, you can then re-populate the form elements using those values.
hth,
bear
[ February 24, 2003: Message edited by: Bear Bibeault ]
 
Wally Schnok
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup, i need to display on the same page various controls that are different if i change a different option from the select.
so,i should not do submit , but have an event ( i tought to refresh )that re-display my page when i make my selection in the combo WITHOUT pressing a submit button or something like this
:-DDD it sounds impossible , it's clear your solution with teh servlet but how can i call a servlet without pressing a button ??? is there some way ?
( even in struts , i have tomcat and struts .... )
thnx
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your onchange handler you can submit the form (let's say it's named editForm) with:

This will cause the form to submit just as if a button of type "submit" had been clicked. Make sure that your form action is set to the correct servlet (or other server-side handler), which you can also manipulate from your onchange handler if need be.
hth,
bear
[ February 24, 2003: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic