• 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

appending where clause forEach?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code works. I believe it is because I have a Rule.java object as my middle tier and a RuleDAO.java object as my backend and the jstl tag somehow magically knows this. If I experiment and change the name of my class, or change the name of the list in forEach, the data does not surface in my list. So I am going forward with a bit of faith. My next step is to try to modify the query that is being executed in RuleDAO.java based on the dropdown lists that I have added. User will choose values from the selection boxes and I will take their selected values and "SOMEHOW" create a where clause that I can use/append to the magic of the forEach.

Two questions, obiwan (or obiwans).

1. Is this possible or do I have to use another approach.
2. If possible, can I get a hint?

:-

 
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
Nothing happens by magic. The JSTL tags will only know about what is explicitly created as scoped variable. I'd assume that's being handled by the page controller.

If I understand what you are asking: no, you cannot affect the functioning of the forEach tags via user actions that happen after the JSP has been evaluated and the response sent to the browser.

Or are you assuming that the selections have been made in a previous request?

P.S. What's with the import declarations? Superfluous code is dangerous code.
 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. Bet I could easily do this in the controller, based on what is passed in the request.
 
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
I"m confused. If the response hasn't been sent to the browser yet, how can you know what the user will choose in the future?

Or, asking again: are you assuming that the selections were chosen in a previous request?
 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I should restate what I want, now that I am closer and...
I have the page that displays a list of all rows.
I have added a form and a number of select boxes.
When the user first requests the page, they get all rows. Then, they can choose to filter by selecting values from the dropdowns. When they submit the form, I do a 'Get' instead of a 'Post' and drop through code in my controller where I can build my where clause, then call a different DAO method that handles the where clause and returns a jimited rowset.
 
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
OK, sounds straight-forward enough. It doesn't seem to have much to do with the forEach tags though. They'll just iterate through whatever is sent to the JSP.

What's the real issue?

P.S. I've done similar things in the past; but I would not show all the data at outset. Why bother to fetch and show a bunch of stuff they;re just going to filter away? Or are you also paging as well as filtering?
 
stephen r davidson
Ranch Hand
Posts: 58
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real issue?

I have found, through out my career, that when I am noodling on something, I often times don't know what the real issue is until I begin trying to spell it out to someone. Then, just with the process of give and take, someone, you in this case, says one thing that leads me to a clearer understanding of what I am after. In this case, I was after an approach to build a where clause based on user input -- to filter the list. And I have it -- almost -- working. Next step will be to use the displayTag ( I think that is what it is called) to paginate, and introduce sorting of columns. I believe with displayTag, I will be able to return just a few rows. I didn't intend to return all rows but before I get to pagination, sorting, I had to deal with the mechanism for filtering.

 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

stephen r davidson wrote:I have found, through out my career, that when I am noodling on something, I often times don't know what the real issue is until I begin trying to spell it out to someone. Then, just with the process of give and take, someone, you in this case, says one thing that leads me to a clearer understanding of what I am after.



Absolutely true.

In the worst case you get the second-rate solution implemented and in production before somebody points out the real answer. But yeah, talking to somebody who doesn't know what the heck you're talking about is often a good strategy.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic