This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

appending where clause forEach?  RSS feed

 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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?

:-

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!