Re: MVC + ORM
You could use servlet filters to have the hibernate session open until the request is processed. There are articles in the www.hibernate.org that explains different patterns to handle situations similar to yours... Hibernate session needs to be open in order for the objects to load the collections or any lazy properties... Also, if the object is dettached then you need to re-attach it to the current session for it to be loaded or used... Hope this helps... - Srini [EMAIL PROTECTED] 2/10/2006 11:22 AM I´m using Struts 1.2.8 with Hibernate 3.0.5 and I´m doubt with some concept designs for ORM with MVC: A Hibernate session get's instantiated in my DAO constructor (Model). Later on, the JSP (View) catches the Hibernate persisted objects populated in the request or session by the Controller and shows the data. Question is: If I close Hibernate session in the Model, before the View, as by default the objects are lazy-instantiated, that is, the data would be retrieved from DB when it´s accessed, the JSP complains that session is closed. Besides, closing the session after the View I would be breaking the MVC pattern. I'm trying to retrieve Blob objects not sucessfully, due the problem above... the only way would be disable lazy-instantiation?? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Aladin, I do know that DisplayTag 1.1 has the batch paging capability, that was my first email I sent to this list but my concern was that they had warned that this version is yet to be ready and that they could change functionality (not stable for production)... so I was a little afraid of using it... Thanks, Srini [EMAIL PROTECTED] 1/23/2006 8:48 PM Hi Srini, I have a table that contains 32000 records and was in the same predicament as you. I wanted to subsets of the records rather than the whole thing at once. Also the current release version of displaytag doesn't allow you to paginate (or sort) sublists, you might be surprised to know that version 1.1 does! You just have to checkout the source from CVS and compile it. After compile displaytag 1.1, you can have sublists and external sorting by adding the following paramters to the display:table tag: 1. sort=external 2. partialList=true 3. size=somesize I always resisted using displaytag because of loading the entire resultset is just plain bad when you're dealing with a large number of records. But now that this restriction has been removed, displaytag does the job quite nicely. Hope this helps. Aladin Srini Pillai wrote: Hi, We have a situation where we require to paginate our result list (which is quite huge, around 1000+ records). We found few tags like DisplayTags from sourceforge.net but the current version does not support batch lists (i.e. retrieving the list in batches based on the page the user is in, instead of retrieving all in once). Is there a tag in Struts/JSTL that would help display huge lists. Any help is appreciated. Thanks, Srini - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tags for Pagination
Hi, We have a situation where we require to paginate our result list (which is quite huge, around 1000+ records). We found few tags like DisplayTags from sourceforge.net but the current version does not support batch lists (i.e. retrieving the list in batches based on the page the user is in, instead of retrieving all in once). Is there a tag in Struts/JSTL that would help display huge lists. Any help is appreciated. Thanks, Srini - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Gary, We were thinking of executing an initial query to get the total count for the criteria (using count(*)) and then page it using the offset and range that would be passed as part of the query string when clicked on the page numbers. Also we are using hibernate, which has the facility to specify offset and maxresults to retrieve the range of records to be displayed on the page. The DisplayTag was impressive but the batch part of the implementation is still in the development stage. We couldn't find any tags that could function with a batch list... - Srini [EMAIL PROTECTED] 1/23/2006 3:11:24 PM From: Rick Reumann [EMAIL PROTECTED] On 1/23/06, Srini Pillai wrote: We have a situation where we require to paginate our result list (which is quite huge, around 1000+ records). We found few tags like DisplayTags from sourceforge.net but the current version does not support batch lists (i.e. retrieving the list in batches based on the page the user is in, instead of retrieving all in once). Is there a tag in Struts/JSTL that would help display huge lists. Any help is appreciated. None that I'm aware of:( Although I keep meaning to work on one. Ajax would really be nice for this actually. You could go to the server to get your next display and it would repopulate your display without the whole page refreshing. That would be slick but you would still have the problem of deciding how to batch up your results without actually retrieving the full set. You still need to determine how many rows you want to display and how many pages. Are you thinking of using something like a keyset cursor? Something similar could be implemented using the standard DAO/VO pattern. I've heard this described as ghost objects. The first data retrieval only returns the primary keys populating ghost objects. The set of keys are used to retrieve the details/rest of the object per page. Your initial inquiry returns the full set of keys matching the criteria. Gary - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Adam, Did you use your own custom tag to display the results or did u extend any tags available in the web ? - Srini = I implemented pagination with batched retrieval using Hibernate, which takes a couple of parameters on its fetch methods, maxCount and firstRecord. It's fairly easy except the logic at the front-end was tricky when trying to implement backwards and forward buttons and setting the new firstRecord parameter to store on the jsp for the next submit. Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Thanks, it was quite helpful... I am looking for more of a component (tag) that could plugin nicely without much customization...but looks like we have to code our own tag... Thanks anyway :) - Srini [EMAIL PROTECTED] 1/23/2006 3:31:52 PM On 1/23/06, Srini Pillai [EMAIL PROTECTED] wrote: Gary, We were thinking of executing an initial query to get the total count for the criteria (using count(*)) and then page it using the offset and range that would be passed as part of the query string when clicked on the page numbers. Also we are using hibernate, which has the facility to specify offset and maxresults to retrieve the range of records to be displayed on the page. The DisplayTag was impressive but the batch part of the implementation is still in the development stage. We couldn't find any tags that could function with a batch list... - Srini Srini, you might find this link helpful. http://wiki.apache.org/myfaces/WorkingWithLargeTables - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Thanks anyway... [EMAIL PROTECTED] 1/23/2006 4:39:49 PM Srini Pillai on 23/01/06 20:45, wrote: Did you use your own custom tag to display the results or did u extend any tags available in the web ? = I implemented pagination with batched retrieval using Hibernate, which takes a couple of parameters on its fetch methods, maxCount and firstRecord. It's fairly easy except the logic at the front-end was tricky when trying to implement backwards and forward buttons and setting the new firstRecord parameter to store on the jsp for the next submit. I wrote a tag for it. Pretty horrible I'm afraid, and that's even without page numbers a la google to click back or forwards to. Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tags for Pagination
Rick, Thanks for the guidance...It is a good start for me... - Srini [EMAIL PROTECTED] 1/23/2006 4:37:53 PM On 1/23/06, Srini Pillai [EMAIL PROTECTED] wrote: ...but looks like we have to code our own tag... Thanks anyway :) At least for the display of pages and the whole next/last stuff, make this an open source tag:) I just haven't gotten around to making one myself. It should take something like: sizeOfCollection maxRowsDisplayed currentPage url based on that information it should be pretty easy to create a nice tag that generates google-like page numbers, first, next, last, previous. etc. My thought was the tag would generate those links using the url passed in and append the appropriate pageNumber. On the server side there would be the use of a PagationObject that holds that same information listed above in Session scope. When the user clicks on one of the links from the tag it can figure out based on the pageNumber submited in the link what rows to retrieve from the db. The display part into the table should be pretty easy. For that we could just steal and tweak the display tag code. To me this would be a really nice tag. If you/we/whoever wanted to really go crazy, we could provide a PagationServlet that handles almost all of this but it would obviously then mean a lot more information would have to be passed into the tag such as... collectionName classNameToCallForCollection methodNameToCall or something along those lines. Then our Servlet along with the Pagation object could use reflection to execute the appropriate method to get the List and put it into request scope. (Obviously the developer would still have to make sure to code an appropriate method somewhere that got the Collection based off the row range passed to it). Tie this all in with Ajax to update the display and you have a real winner:) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using c:out with EL replacing bean:write
Hi all, I know this is more of a JSTL question but it would be really helpful if anyone could help me understand the usage of c:out with Expression Language (EL) which replaces the bean:write /. I believe Struts did not implement EL for bean:write / tag and few others and suggests using c:out / instead. I have a situation where I require to use dymanic textboxes based on the certain criteria. To make this work I used LazyValidatorActionForm. It works like a charm but when I want to write out certain form property using EL, it doesn't work well. I am not sure how to use it with c:out /. For example: This is the code I tried to display a link with a value in the dynamic form: c:forEach var=counter begin=0 end=${numTextFields} . a href=html-el:rewrite page=/FAEditor.do/?methodToCall=removeElementid=c:out value=${request['FAEditorForm'].id_${counter}} /Remove/a . /c:forEach Here, I am trying to get the Form from the request attribute and invoke the method for property 'id_?' where '?' can be some number depending on the counter in the loop. When executing this page, I am getting an exception: javax.servlet.jsp.JspException: Can't insert page '/pages/findingaids/FACustomContainerEditor.jsp' : javax.servlet.jsp.JspException: The taglib validator rejected the page: tag = 'out' / attribute = 'value': An error occurred while parsing custom action attribute value with value ${request['FAEditorForm'].id_${counter}}: Encountered {, expected one of [}, ., , gt, , lt, ==, eq, =, le, =, ge, !=, ne, [, +, -, *, /, div, %, mod, and, , or, ||], I also tried using c:set / but looks like the JSTL tags does not allow more than one '{' inside an attribute. Not sure how to solve this issue. Any help is appreciated. Thanks, Srini - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using c:out with EL replacing bean:write
Thanks Rick, for responding quickly. I'm not sure what you are attempting to do with: value=${request['FAEditorForm'].id_${counter}} I am trying to access the value from the ActionForm for property 'id_0', 'id_1' etc... depending on the value of the ${counter}. The example you had suggested using the 'url' tag will not work for me since the 'id' parameter will pass the value of the counter but I require the value in the form for the 'id_?' (where '?' is any number from 0...n) as mentioned above. Hope I am clear. Really appreciate your help. Thanks, Srini [EMAIL PROTECTED] 12/19/2005 10:45 AM On 12/19/05, Srini Pillai [EMAIL PROTECTED] wrote: This is the code I tried to display a link with a value in the dynamic form: c:forEach var=counter begin=0 end=${numTextFields} . a href=html-el:rewrite page=/FAEditor.do/?methodToCall=removeElementid=c:out value=${request['FAEditorForm'].id_${counter}} /Remove/a . /c:forEach struts tags (from what I remember) I don't believe mix that well when used within standard html tags. I think it'll look cleaner anyway using the c:url tag: c:url var=url value=FAEditor.do c:param name=methodToCall value=removeElement/ c:param name=id value=${counter}/ /c:url a href=${url}Remove/a I'm not sure what you are attempting to do with: value=${request['FAEditorForm '].id_${counter}} but I doubt you need that . You just probably need the id from the counter, if not you'll have to explain why not and I could try to help. -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using c:out with EL replacing bean:write
Craig, The looping I had mentioned is for displaying the text boxes (which grows dynamically) as well. Not sure how I could move that to the action class. Unless I am missing something. I understand the fact that the arguments and values for a link can be fed as a Map as you had suggested but the (Remove) link in my example is present for each row of the textboxes present in the page. Below is the exact situation we are facing, It would be really helpful if you can comment on it: We need a bunch of dynamic textboxes laid as a table. Each row (containing a set of textboxes) in the html table represents a group of rows in a db table (i.e. 1 html row to many database rows translation). User can add more (empty) html rows on the page to create new entries into the db. The 'Remove' link is present for each html row if the row is persistent. The Remove link on each row will contain only one argument: 'id' which, for now, is part of the form, so as I iterate to display the textboxes, I create the links based on the id value for that row... Thanks, Srini [EMAIL PROTECTED] 12/19/2005 12:48 PM On 12/19/05, Srini Pillai [EMAIL PROTECTED] wrote: Thanks Rick, for responding quickly. I'm not sure what you are attempting to do with: value=${request['FAEditorForm'].id_${counter}} I am trying to access the value from the ActionForm for property 'id_0', 'id_1' etc... depending on the value of the ${counter}. The example you had suggested using the 'url' tag will not work for me since the 'id' parameter will pass the value of the counter but I require the value in the form for the 'id_?' (where '?' is any number from 0...n) as mentioned above. Hope I am clear. Really appreciate your help. As you have noticed, the EL syntax is not up to the task you're after (of course, bean:write is not going to be, either). But, I suggest you consider a completely different approach. When you execute an EL expression like this: ${foo.bar} what's really happening is that a bean named foo is found, and then it's getBar() method is called. So, why not write a getBar() function on some bean class that returns the entire set of argument names and values for you? In other words, do the looping in Java code rather than JSP. If this method were on the same class that contains the list or array being iterated over, it should have everything it needs to calculate the appropriate parameter values. As a general principle, I believe that manufacturing URLs in the JSP code (as you are attempting here) is working too hard ... and it is really mixing elements of the controller into the view in undesireable ways. Much better to write code in the controller that can calculate all that stuff for you, and then let the view code pull it out with a simple EL reference. Thanks, Srini Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]