• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

Displaying button click results on same view using model which is based on value entered from view

Ranch Foreman
Posts: 2024
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a view from which user can enter value an option from text box and based on the value of option entered by the user, data from the model will be displayed on the view. This works fine if I used 2 views. One for entering the text box option and other for displaying the results. However if I try to to this in the same view, it gives object reference not set error. This is because the model is available only when user enters the text box value and before entering the value itself it will give object reference not set. How can I achieve this using single view?

The code which works fine using 2 views:





This is the URL using which I run it on local:


The above code works  but how to achieve the same using a single view instead of 2 views?


Monica Shiralkar
Ranch Foreman
Posts: 2024
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is coming fine now after I have put a null check. Now a new issue has come that is it shows the if statement in the response itself.

This is the code that I have changed:

It shows response as this and shows even the if statement in the response:
if(model!=null) {
1 Richard Thomas
2 Tom Mathews
3 Ronald Walter

How can I avoid the if statement to print in the reponse?
Is that a spider in your hair? Here, threaten it with this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic