Again, displaytag is a tag library for displaying things.  You're asking for
a very open-ended form management tool.  That isn't what displaytag is.  It
does the job for which it's designed very well.  It shouldn't be surprising
that you find that a hammer is not so good for screwing in bolts.

You'll notice that there are NO functions whatsoever in displaytag to handle
processing posted form data.  That's quite deliberate.  That doesn't mean
that it can't be a part of your solution though.  Just don't ask it to do
something it's not meant to do.

That said, I think you can quite easily use displaytag to generate the form
that you want.  Can you please describe what you would like to do?  If you
can create some HTML that shows an example of the type of form you'd like to
show to your users would be good also.  If I understand what you want to do,
I think I've implemented a number of solutions that do almost exactly what
you want.  I just want to make sure I understand exactly what you want
before I describe a solution, as in the past I've solved an entirely
different problem from what people were asking for :)

Rick Herrick
[EMAIL PROTECTED]


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:displaytag-
> [EMAIL PROTECTED] On Behalf Of Harakiri
> Sent: Monday, May 29, 2006 6:23 AM
> To: [email protected]
> Subject: [displaytag-user] Editing / Saving ALL current displayed
> entriespossible - but bad design
> 
> Hi list,
> 
> the demo of editing and saving entries using display
> tag
> http://demo.appfuse.org/appfuse/demos/users-edit.jsp
> has the obvious limitation of only allowing ONE entry
> to be manipulated at each request (save)
> 
> Ive found a simple way to edit all entries current
> displayed however - the design is bad i think and if
> displaytag would offer more manipulation abilities it
> would not be needed.
> 
> Problem 1.
> 
> I needed to know WHICH entries the user currently
> edits / views - displaytag does not tell me that on a
> submit of a formular. If i knew which entries are
> currently displayed i can manipulate this data i.e. by
> 
> 
> ArrayList entryListDisplayed =
> (ArrayList)session.getAttribute("entryListDisplayed");
> 
> // entryListDisplayed - the list of entries which
> // are currently being edited / viewed by the user
> for(int i=0; i < entryListDisplayed.size(); i++) {
> 
> User currentUser = (User)entryListDisplayed.get(i);
> currentUser.setSomeField(request.getParameter("SOMEFIELD_"
> + currentUser.getId()));
> 
> }
> 
> Request for Displaytag :
> 
> Displaytag could put the currently viewed members of
> the list into a seperate list and that list into the
> session. i.e.
> 
> <display:table id="user" name="entryList"
> currentlyDisplayed="entryListDisplayed">
> 
> My Solution :
> 
> As long as display tag does not supply such data
> manipulation - i have to use something like this :
> <%
>    ArrayList entryListDisplayed = new ArrayList();
> 
> %>
> <display:table id="user" name="entryList">
>   <% User currentUser =
> (User)pageContext.getAttribute("user"); %>
> 
>   <display:column property="name">
>    <%
>          // memorize entires which are currently shown -
> needed for save - can be in any column but must be
> within <column>
>         entryListDisplayed.add(currentUser);
>         session.setAttribute("entryListDisplayed",
> entryListDisplayed);
>       %>
>  </display:column>
> </display:table>
> 
> I figured out that any code within a display:column
> tag is only executed for entries which are currently
> rendered i.e. displayed to the user - so now i do know
> which entries the user currently sees.
> 
> Problem 2.
> 
> With the possibility of editing all currently
> displayed data on a given page - you should (need) to
> remember on which page you currently are and which
> sorting you currently use. I.e. the user changes some
> entries on page 4 - after submit he would be on page 1
> again not on page 4. So not only the currently
> displayed data needs to be hold into a session but
> also the currently used view parameters (page number,
> sorting etc)
> 
> Request for Displaytag :
> 
> Either supply a build in function for my own save /
> edit links which adds the current pagination url
> parameters to my link or store the current sorting
> into a session var i.e.
> 
> <display:column title="Delete User">
>       <a
> href="mypage.jsp?action=deleteUser=&id=${user.id}<display:getProperty
> name=currentPaginationURL>" >Delete</a>
>   </display:column>
> 
> My Solution :
> 
> within the list i found somebody else with the same
> problem he wrote a method which extracts the current
> pSOMEVALUE=1 parameters - i modified it a bit to
> include all parameters and use it now :
> 
>  // find the internal url request params from the
> display tag libary
>       public String
> getDisplayTagOrderParams(HttpServletRequest myRequest)
> {
> 
>               if(myRequest == null || myRequest.getParameterMap()
> == null)
>                       return "";
> 
>               java.util.Map pm = myRequest.getParameterMap();
>               String page_par = null;
>               String sort_par = null;
>               String order_par = null;
> 
> 
>               for( int i=0; i<pm.size(); i++){
>                       java.util.Iterator it = pm.keySet().iterator();
> 
>                       while(it.hasNext()){
>                               String next=it.next().toString();
> 
>
if(next.substring(next.length()-2).equals("-p") &&
> next.substring(0, 2).equals("d-") && page_par==null)
>                                       page_par=next;
> 
>
if(next.substring(next.length()-2).equals("-s") &&
> next.substring(0, 2).equals("d-") && sort_par==null)
> 
>                                       sort_par=next;
> 
>
if(next.substring(next.length()-2).equals("-o") &&
> next.substring(0, 2).equals("d-") && order_par==null)
>                                       order_par=next;
>                       }
>               }
> 
>               String result = "";
> 
>               if (order_par != null &&
> myRequest.getParameter(order_par)!=null &&
> !"".equals(myRequest.getParameter(order_par)) ) {
>                       result+="&"+order_par + "=" +
> myRequest.getParameter(order_par);
>               }
> 
>               if (sort_par != null &&
> myRequest.getParameter(sort_par)!=null &&
> !"".equals(myRequest.getParameter(sort_par)) ) {
>                       result+="&"+sort_par + "=" +
> myRequest.getParameter(sort_par);
>               }
> 
>               if (page_par != null &&
> myRequest.getParameter(page_par)!=null &&
> !"".equals(myRequest.getParameter(page_par)) ) {
>                       result+="&"+page_par + "=" +
> myRequest.getParameter(page_par);
>               }
> 
>               return result;
>       }
> 
> then i simply just use these in every jsp and add it
> to my auto generating links i.e.
> <% String orderParams =
> getDisplayTagOrderParams(request); %>
> 
> <display:column title="Delete User">
>       <a
> href="mypage.jsp?action=deleteUser=&id=${user.id}<%=orderParams%>"
> >Delete</a>
>   </display:column>
> 
> 
> 
> Problem 3.
> 
> When a user is on page 2 i.e. and only 1 entry is
> displayed and the user issues a delete action for this
> entry some odd behaviour is seen. Since i remembered
> the current sorting / pagination while issuing the
> save - displaytag would try to display page 2 again
> but sees there are no entries left - therefor it
> correctly displayes page 1 - HOWEVER - only columns
> without any code are displayed correctly i.e.
> 
> <!-- displays the value -->
> <display:column property="name"/>
> 
> <!-- does NOT display any value - empty -->
> <display:column title="email">
> <% doSomething(currentUser.getName()) %>
> </display:column
> 
> after clicking on page 1 again it (i.e. displaytag
> does not try to render an empty page 2) it will
> displayed correctly.
> 
> I have no solution for this problem...
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> 
> _______________________________________________
> displaytag-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user


_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to