Re: [OT] How to load a csv file into java
Hi Richard, I need to load exported information ( csv file ) into POJOs. How do I do this? Well, just use the tag (and don't forget tu use the correct attributes in your tag). Then converting your CSV file'll only be a matter of split()ing the resulting data... Well, more or less ;-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: accessing variables using logic:iterate
Dave wrote : As a followup, you may want to consider switching to JSTL for straight-forward tasks such as this: where functionality is duplicated between the Struts tags and JSTL it's generally recommended to go the JSTL route. It's a trivial switch to make, and can be done mechanically in most cases. I totally agree with this statement. In addition of being a way to get more "genericity" in the JSP, it is (IMO) quite more coherent. What I really dislike with struts tags is that attributes don't always mean the same thing from tag to tag, which is disturbing. I'm mainly thinking of the "name" and "property", and ".*Name" attributes too. -- Stéphane ZUCKERMAN - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: accessing variables using logic:iterate
Hi Jay, session.setAttribute("recurringTaskSummary",v_recurringTaskSummary), SpRecurringTaskSummary [...] has certain variables such as EmployeeName, EmployeeRef etc. I am using logic:iterate as follows: The output is name of objects. However I want to somehow access the variables employeename, employeeref etc. How do I do that ? Just do something like : Don't forget to use the bean naming conventions, though. -- Stéphane ZUCKERMAN - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MVC Question
I guess my question is: is the action form considered part of the model? If not, what? I think the question's been asked (in a different way) a few days/weeks ago. Here's what Frank W. Zammetti said about it : " The Model is something, conceptually, outside of Struts. Struts provides nothing for dealing with the Model. Imagine that you write some classes that know how to talk to your database, know how to perform your business logic. Further imagine that these classes have a known set of methods (i.e., expose a known interface) that can be called to form the application. More specifically, imagine you have an application where you want to be able to maintain a list of students and what classes they are taking in school. Without arguing about how best to actually architect this (i.e., let's forget about DTOs and DAOs and persistence layers and all that and keep it simple), you might come up with something like this: Class Student - Method: List listStudents() lists all students in the database Method: void createStudent(String studentName, String ssn) Creates a user with a given SSN in the database Method: Map getStudent(String studentName) Gets all the details for a given student from the database Method: void addClass(String studentName, String className) Adds a class a given student is attending Method: void deleteClass(String studentName, String className) Deletes a class a givent student is attending Method: List listClasses(String studentName) Lists all the classes a given student is attending >From this you can create a webapp that allows you to list students, pick one, see their details including what classes they are taking, and add and remove classes. Again, we're ignoring how you really should architect this, I'm just trying to get the basic point across. Also note that this is completely independant of the fact that you are writing a webapp. You can just as easily write a Swing-based client that uses this class, or any other presentation technology. Now, you have a single class that exposes a known interface that for all intents and purposes represents your model. Now, from your Struts Actions, you call these methods and render the results as appropriate. The method parameters like studentName and className would probably be coming in as request parameters, so you just instantiate your Student class and call the appropriate method, then take the result and pass it to the view for display. Struts itself doesn't deal with the model for you. How you get at these classes is also up to you... could be a JNDI lookup, could be just included with your app, etc. Struts leaves this to you entirely. Hope that answers your question :) " -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String concatenation
Konrad Billewicz a écrit : do you need to put dictionaryId to querystring? i come up with "> as an alternative It is a good idea. But... shouldn't I avoid using non-Struts HTML form tags in Struts-driven applications? I am quite new in Struts and I don't want to get bad habits. :-) In the Struts framework, you have to avoid including logic in the presentation layer (JSP), but this is only a recommendation. Frankly, I know of no other way to concatenate strings for instance than the one I already told you about. I have no code whatsoever in my JSPs, but for those tiny little things (use of constants where I can, and use of concatenation where I must). -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSF is the beginning of the end of Struts !!!
John Henry Xu a écrit : Actually, my favorite sites are the ones that map "*.asp" to the Struts servlet. Gotta love people that bend minds like that! I cannot imagine what motivates people tried to map there servlets to .asp. Even I could easily map my site to .aspx, I would not do that. Although I respect MS, I am not really a huge fun of Microsoft. If I implement sites with Java, I want java take credits. If I implement sites in PHP, I want PHP take credits, I would not map that to .asp. If I use .net, I don't map it to jsp also. If I saw a site ends with .php or .aspx, I assume that was a php and .net site, and I belieave I am right on that with 99% confidence. I guess this is against wannabe crackers. Yes, yes, I know, security through obscurity, blah blah blah... Well, once you've done everything that isn't obfuscation-related, there is only obscurity that remains, and frankly, it does help gain a few {minutes,hours} before the nasty black hats break the server. :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String concatenation
Hello Konrad, I'm not sure I've understood correctly what you want to do, but here's what I would do : value="<%= SomeConstantsHolderClass.CONSTANT_STRING + SomeConstantsHolderClass.CONSTANT_STRING %>" /> ... Don't forget that you can still use an action _before_ you go to your JSP to prepopulate it. And by the way, in the JSP, everything is toString()ed, if I'm not mistaken, so you can always do something like -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSF is the beginning of the end of Struts !!!
Craig McClanahan a écrit : Tell me again how you come to the conclusion that Java is not a popular platform for web app deployments? (To say nothing of the fact that Microsoft might dispute the "PHP is king" rubric as well :-). I think this is always the same old argument : what we see on the web are "Web sites", while J2EE is often (mostly ?) used for "Web applications", which don't have the same goals at all. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Re: SelectAction - an improved DispatchAction
Mmmh. Not always - at least, not in French right, for instance. If there is no license tied to code on a web site, but said code is clearly defined as Mr X's code, then it is implicit that you don't have the right to use it, integrate it, etc. for whatever purpose unless you have some written (1) authorization from Mr X. If you use the code for your personal needs and don't publish the code or try to make money with a derivative from it, what I've just said doesn't apply, of course. Now there is always the matter of "common sense", which would have us think that since the code is available for free, without anything written about using it, then it should be alright to reuse it. Most of the time, this assertion is correct. Sometimes it is not (just think of the "GIF problem" a few years ago - I know, this isn't the same kind of problem, but it is related in some way). (1) : well, "written", or at least "perfectly non-ambiguous". -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The idea that someone has "ownership" of code anyway (legalisms aside) is somewhat megalomaniacal. I don't think anyone can code even a single line of code without benefiting from someone else's work. Should we comment credit to the GOF every time we apply a design pattern? If I remember correctly, your are explicitly allowed to use the code given in their book, and as far as I can remember, every CS/IT book I've read has made the same explicit authorization. Should we ask for permission every time we google our way through a problem and integrate the code (yes, even using copy/paste) into our package, then distribute it to the public? This is already another kind of code reuse. And if the web site is done "the right way" (whatever that might mean), you should be able to see somewhere on the web site that you do have a right for reusing the code you saw. This idea that "you sole my (his/her) code" only applies when the code was literally stolen: forcefully or covertly taken. This is what happens in practice, yes. Now imagine someone does this wonderful library, which is very convenient. For YOUR kind of development, this is The Right Tool. And you're not the only one to think that way. And now, the "owner" of this library starts saying "hey, I've never said that you could do some commercial stuff with MY library". Like I said, this is more or less what's happened with the GIF image format, excepted that there was a patent on it which was never used, until it became apparent that everybody on the web was using this image format (at least at some point in Internet time :-) ). In the end I agree with you of course. But that doesn't mean that, in the law's point of view, you (or me, or anyone sensible around) are right. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DB Connection
Senthilrajan VS a écrit : Hi Stéphane Zuckerman, Thanks for your response. Can u please tell me how can I close the connection if the user close the window directly because I am not maintain any session in the window These are two unrelated events : you want a client-side event to create a server-side event. I don't know enough JavaScript to help you an "onClose" event (I don't even know if that exists). You'd better use a link to make the session close, and if you really don't want to have a session to stay opened too long, just shrink its timeout to a few seconds. :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DB Connection
Vijay K Anand a écrit : hi How to share the saem db connection across user requests..without exhausitn the connection pool. regards Vijay You could create a plugin that connects to the Database when launching the webapp, then put the handler in the servlet context. Then you could retrieve it from there, or try to put it in the session scope at the beginning of the user's session. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: SelectAction - an improved DispatchAction
Craig McClanahan a écrit : On 7/21/05, Dakota Jack <[EMAIL PROTECTED]> wrote: This code does not belong to Michael. It is purloined from www.michaelmcgrady.com and other discussion on this list. In the midst of chuckling at the assertions made in this thread, a serious comment for DJ (and others like him) to consider. Publishing source code on a public web site, without any associated license, as was done here, is basically putting that code into the public doman. If you want to assert ownership rights, you might think about a different behavior. Mmmh. Not always - at least, not in French right, for instance. If there is no license tied to code on a web site, but said code is clearly defined as Mr X's code, then it is implicit that you don't have the right to use it, integrate it, etc. for whatever purpose unless you have some written (1) authorization from Mr X. If you use the code for your personal needs and don't publish the code or try to make money with a derivative from it, what I've just said doesn't apply, of course. Now there is always the matter of "common sense", which would have us think that since the code is available for free, without anything written about using it, then it should be alright to reuse it. Most of the time, this assertion is correct. Sometimes it is not (just think of the "GIF problem" a few years ago - I know, this isn't the same kind of problem, but it is related in some way). (1) : well, "written", or at least "perfectly non-ambiguous". -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Hibernate vs. iBatis vs. POJO
[EMAIL PROTECTED] a écrit : Hibernate Synchronizer is an Eclipse plugin that generates the config and mapping files as well as the VO/DAO classes. So, unless you want to hand-crank it OR you are an anti-Eclipse zealot, I suggest that you visit http://hibernatesynch.sourceforge.net/. Takes about an hour to have Hibernate running in your code, regardless of number of tables that you need to use. The amout of time saved is certainly worth the $25 donation I made. I think their new tag line is "Hibernate...it's not just for medium/big projects anymore!" ;) Well, I use the MyEclipse plugin, which does exactly the same thing. :-) But the time spent to learn how to configure correctly Hibernate, and know really well how yo use it can be quite long indeed. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: Updating JSP causes Workspace to auto rebuild.. causing Tomcat to restart :(
[EMAIL PROTECTED] a écrit : Updating JSP causes Workspace to auto rebuild.. causing Tomcat to restart :( I'm now turning off auto build when working in jsp's, obviously forgetting to switch it on when doing java class changes Any other way this can be solved? I suppose you're using the Eclipse IDE. Are you using a plugin ? Which one ? With MyEclipse and JBoss, I do not have this behaviour. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Hibernate vs. iBatis vs. POJO
netsql a écrit : So are you saying Hibreante for big complex or iBatis for big complex? I don't know about iBatis, but Hibernate is definitely for medium to big projects. The real "complexity" of Hibernate is in its configuration (there is more or less one Java class for each table in your DBRMS, with one XML configuration file, and a "global" config file to describe general behaviour). After that, using Hibernate is quite easy really. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Hibernate vs. iBatis vs. POJO
Larry Meadors a écrit : I think I would still like to have the freedom of writing normal SQL queries while having the flexibility of using a mapping tool. I guess Hibernate does provide that kind of flexibility. Wo, you did a great job of describing iBATIS for not ever using it: It uses normal SQL queries, and maps them to POJOs or normal java Collections. Not quite the same really, if I understand well what you're saying. In Hibernate, although you can still use real SQL queries, most of the time you don't. You rather use HQL (Hibernate Query Language) to get your queries done. Suppose you have three tables : customer(custId,name) * <- buys -> * good(goodId, label)* <- sold by -> * shop(shopId,name) this leads to this data logic model : customer --- customer_good --- good_shop --- shop Getting a particular shop from customer_goods means doing something like Query q = hibernateSession.createQuery("select cg.goodshop.shop from CustomerGood as cg where cg.goodshop.shop.name = :shopname"); q.setString("shopname","Wall Mart"); List shops = q.list(); With this query language, you can get "through" tables quite easily. However, I agree with previous comments saying that Hibernate is useful if your project is quite large. Otherwise, the time taken to set it up would be better used to do something else. It does add some complexity when thinking through a new project, and in case of an existing one, there are too many changes that would need to be done to it to be really interesting in my opinion (or else, said project wasn't really big anyway). -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkbox
Hi Vijay, How to make checkbox checked in ? One way is to prepopulate the form property with the values you want checked. It works for me. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I remember now why I said I usually use my VO in my ActionForm
Hello Laurie, I found myself faced with the same question recently, and couldn't figure out a solution. The 'obvious' solution was to use Map-typed properties in my DynaActionForm declaration, but that didn't work :-( What was the problem ? I have used map-typed properties (which, by the way, prevents me from using the validator plugin correctly on these properties, since I never really know how many {key,value} couples I'll have), and ran into several problems, but in the end, there are two solutions I can think of : 1/ Use a session-scoped form (I think this is bad design, but sometimes, it does comes handy). 2/ Use a LazyMap (just as you would use a LazyList ;-) ). The problem is always the same with "classical" maps (and it is the same for the lists) : You have a request-scoped object (a map/a list), which is initialized when loading the JSP and sending the result to the client. But when the latter submits his/her form, the entries in said object aren't initialized. for instance, if you have a text field such as : The 'hello' key might have existed in the past, but since this is a new request, it does not any more. You should look at http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html for more information... -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I need help running an example
Mohamed, First of all, you should understand that using JBoss, Tomcat (which implicitly is run under JBoss), or any other application server doesn't change anything. If you embed the right libraries (jar, ear, war, whatever), everything should work fine for your server. Anything else is a problem coming from your web app. This piece of code just means that if the role "Administrator" has been defined for the current user, then it should display the "submit" button. Otherwise, the submit does nothing. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to hide URL in Adress bar?
In my opinion showing the same URL for all pages is a very bad solution. Why is it needed? I don't know for the original poster, but what bothers me is the fact that one can see the parameters in the url displayed. Apart from that, Having different URLs seems a normal behaviour... -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to hide URL in Adress bar?
change all transmissions from method="GET" to method="POST" Is there another way ? I do use the POST method when I can. But some specific processes need to be done via GET (or at least I don't know how to do them with POST)... -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AW: Newbie: Where to put instance for database access?
[EMAIL PROTECTED] a écrit : Should it be stored in the ServletContext for application scope? But how do I access this instance from my Actions? getServlet().getServletContext().getAttribute(xxx) is it the same as request.getSession().getServletContext().getAttribute(xxx) ? Yes. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and Generics
Hello Kent, I'm wondering whether it's possible to use generics with struts. I strongly doubt it, since J2EE isn't using the Java 1.5 SDK, but 1.4 . Now, maybe am I saying something stupid. :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to create form rows dynamically
Ciaran Hanley a écrit : Can somebody help me or propose a solution to the following please. I wish to create a form dynamically. Depending on the business logic there could be 0 to N rows in the form. I tried to use a form with an array of strings and use the indexed="true" setting in the html:text boxes but as I was not following any example I ran into problems and didn't have any guide as to where I was going wrong. I also need to iterate over a bean containing information which corresponds to the form as the form boxes are being displayed. Say if there is 3 rows required, it should ok like the following. Payment Old AmntNew Amnt Date 1 35 [45] [12/12/04] 2 35 [45] [12/01/05] 3 35 [45] [12/02/05] Where [] represents a html:text box. I am also unsure as to how to access these values when I get to the form/action classes. Any help would be much appreciated! There are a few ways to do that. The most obvious (according to me) would be to have a "Billing" (for instance) class, with all the attributes that suit you, then : - use a lazy list (go to http://wiki.apache.org/struts/StrutsCatalogLazyList for more information about them) to store them. The use of LazyList instead of "classical" List (with ArrayList) is all about indexes : when you start from the server and you display the items stored in your list, all is fine. (something like : ) But when the user clicks on the submit button, a horrible thing happens : IndexOutOfBoundException (because a new List is instanciated from the server side - the old one has been lost as it is a new request - and currently, something like formList.get(0) returns null, which isn't what Struts expected). So you have to make some mechanism to return an object (preferably of the right kind) so Struts remains happy. Hence the LazyLists. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AJAX: Whoa, Nellie!
Jesse Alexander (KBSA 21) a écrit : Well,... If we look behind the problems that could arise with JavaScript... I am really convinced that JS in a webapp is a really BAD idea. Think about Cross-Scripting. It is not that your web-applicaiton is the culprit, but someoneelse's bad-behaving Javascript that does the damage. I am just waiting to here about the first case where a developer has to take the responsibilities for real damage to a use, because he required JS for a web-app and in this way forcing the user to switch on JS-support in his browser, rendering him susceptible to damage by another websites ill-behaving JS-code... I also think that a well-designed web-UI does not need JS at all... Mmmh. Well, Firefox lets users choose which site have the right to popup() or not. Let's do the same for JavaScript, and the problem disappears (of course, the other browsers should do the same). -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AJAX: Whoa, Nellie!
Rodolfo García Esteban/CYII a écrit : Where do we find information about this marvellous stuff? Rodolfo __ Look for "XMLHttpRequest" and/or ActiveXObject("Microsoft.XMLHTTP") XML.com and the Apple dev center have good introductory articles about it. Basically, this is a way to make server call from JavaScript via the XMLHttpRequest (Safari/Gecko browsers) or XMLHTTP (Internet Explorer) objects. Thus it enables you to make dynamic calls to refresh some parts of a web page without reloading everything. This is used with gmail for instance. -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AJAX: Whoa, Nellie!
Dakota Jack a écrit : This is a fundamental shift in architecture that makes clear sense. I tend to agree with you, and if this were to be integrated in Struts, my life would be easier (I am using AJAX stuff in some parts of my webapp). However, I have a serious concern related to security : this is still JavaScript :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: LazyLists and dynamic forms
Hello, and sorry for the late answer... Niall Pemberton a écrit : What you have looks OK to me - except in the Action the reference to DynaValidatorForm - looks like your referencing the wrong class to me - You're right, I just mistyped it, but it is a BeanValidatorForm. the actual ActionForm flavour should be a BeanValidatorForm - but IMO its better to just cast it to a DynaBean, then your not fixed on an implementation. Something like... public final class DynaLazyAction extends Action { public ActionForward execute(...) { DynaBean dynaForm = (DynaBean) form; // here is the line that makes it all crumble... Person[] persons = (Person[]) dynaForm.get("persons"); request.setAttribute("persons",persons); return mapping.findForward("ok"); } } Also when you say "here is the line that makes it all crumble" - what does that mean? Presumably your getting an Exception thrown - if so, what is it? The exception is a ClassCastException ... Which is really strange, since the bean is supposed to store exactly the object I'm trying to retrieve ... Thanks for your answers ! :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: LazyLists and dynamic forms
Niall Pemberton a écrit : Its hard to help when all you say is "failed to make their examples work". Posting snippets of relevant bits of your struts-config.xml, jsp etc would help along with what actually happened. Sorry for the lack of details, I know I was really too vague. I am using Struts 1.2.4 . So, here is what I want to do : I have a list of text fields which number is unknown when the user gets to the JSP. Fields are added dynamically through JavaScript. Now, I know there is Struts 1.2.6 on its way, but I can't wait for it to get a "stable" label. So here is the example I was trying to follow (extracted from http://wiki.apache.org/struts/StrutsCatalogLazyList) : [quote] In fact using Arrays (rather than Lists) a LazyDynaBean can be used directly, in the following way: [/quote] Supposedly, the LazyDynaBean object should be wrapped within a BeanValidatorForm one. Here is what I am using in my struts-config.xml file : The class Person is really just a bean, with deux properties : name and fname. Here is the JavaScript code I use to generate new text fields : function foo() { var nb = document.getElementById('nb').value; var f = document.getElementById('f'); f.innerHTML = null; f.innerHTML = "nb: "+ ""; for (var i = 0; i < nb; i++) { f.innerHTML += "name: "; f.innerHTML += "first name:"; } f.innerHTML += ""; } The JSP is really basic (since this is a test) : JSP for lazyForm form nb : ... And my Action class is as simple as the JSP : public final class DynaLazyAction extends Action { public ActionForward execute(...) { DynaValidatorForm dynaForm = (DynaValidatorForm) form; // here is the line that makes it all crumble... Person[] persons = (Person[]) dynaForm.get("persons"); request.setAttribute("persons",persons); return mapping.findForward("ok"); } } As I said before, when it is about "manual" forms, everything's fine, I use LazyLists, and it works (thank you so much, Rick; you made my morning wonderful :-) ). I hope I wasn't too messy in my explanations ... Thanks for any clue you might give me :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Anxiously awaiting...
Hello, Ex.: [code] ${emply.firstname} [/code] Have you tried to do just that ? -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
LazyLists and dynamic forms
Hello, I've read carefully the Struts' wiki page regarding indexed properties and how to deal with them... but I failed to make their examples work with LazyDynaBeans ... Could someone put me back on track please ? I've managed to use LazyLists in classical ActionForms, and if there is no other choice I will continue that way, but since I've got all my other ActionForms in a dynamic way, I'd rather stay coherent with my project... Thanks -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to submit a variable number of text fields ?
Good stuff on LazyList here http://wiki.apache.org/struts/StrutsCatalogLazyList Thanks a lot for your help ... I think I'm as confused as you (maybe more !), even after reading the thread related to your question... I think I need a simple example (something like a form in a JSP, an ActionForm - or a DynaActionForm - processing it, an Action, and finally a JSP page for results display...) I'll try to build one... :-) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to submit a variable number of text fields ?
>> What's the error you are getting? I haven't looked at everything but >> the above "name='persons["+i+"]name' />" should be >> "name='persons["+i+"].name' />" Ops. In the original JSP, there is no such mistake ;-) Rick Reumann a écrit : Also you will be getting errors when you submit (probably index out of bounds exception) That's it ! because your intial String[] isn't large enough. OK, that explains my problem then. I think if you use a LazyList things will be easier. If you use indexed properties for a String[] things are going to become more tricky (although I think there might a lazy array type also). Can I use "simple" Lists as well ? Thanks a lot for the help anyway ! -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to submit a variable number of text fields ?
Hello again, Let me try to define a simular problem that I have that would most probably answer Stéphane's. But only Stéphane can confirm this. :) Well, I do ! :-) This is the same kind of problem I have encountered. I don't use a list, just an array (although a List would do just fine, of course). For instance, I have something like public class Person { string name,fname,email; // then setters/getters ... } ... and a form a little bit like this : function addMoreFields() { var f = document.getElementById('f'); var nb = document.getElementById('nb').value; f.innerHTML = null; f.innerHTML = "<input type='text'" + " value='" + nb + "' id='nb' " + onchange='addMoreFields() />'" for (var i = 0; i < nb; i++) { // here I'd need to make indexed properties // work, sth like : f.innerHMTL += "<input type='text' " + "name='persons["+i+"]name' />"; // ... and the same for fname and email ... } } I use DynaActionForms : (excerpt from struts-config.xml) So basically, When I retrieve the Person[] object in my Action class, the length of the array is 0... Which is quite annoying, since I've filled "nb" sets of fields ... ! :-) I hope I am a bit clearer now :-) Thanks for the help ! -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to submit a variable number of text fields ?
Hello, I'm trying to submit a form where the user fills a field with a number, making text fields appear (via Javascript). I've looked around for indexed properties, but the examples aren't addressing my problem, and suppose that the collection where one iterates is already created... Thanks for any advice ! Stéphane -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts + Ajax + Firefox
Joe Germuska a écrit : I don't think this is a problem with Struts, rather with Firefox and its way of handling XMLHttpRequest... But is there a way to bypass this behaviour ? I don't think you can use ActiveXObjects in Firefox -- you certainly wouldn't be able to reach users of non-Windows systems. I am not (in fact it wouldn't be working at all if it were an ActiveX object :-) ). -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Actions and form methods ...
Erik Weber a écrit : Try using request.getParameterNames to see what's actually being delivered to the server. I did try it (although I should have mentionned it). I've progressed a little so far : it seems that if I type the url directly inside the navigation bar, it works. But in fact it is a javascript function that does the request (I use an XMLHttpRequest, that does something like req.open("GET","http://localhost:8080/req/test.do?q=foo",true); But then the query string "disappears" (well at least, it doesn't reach the action ...) -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Actions and form methods ...
Hello, Are the Action classes only processing "POST" forms ? I am asking this because I'd like to give some parameters to an Action I am creating, and can't get no result with the request.getParameter() method... Thank you for your time -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts + Ajax + Firefox (was: Best practice for "dynamic reloading" of a part of the JSP ?)
Frank W. Zammetti a écrit : I reposted it at the same address. Of perhaps more interest though... I am working on an article covering this in more details with a few more examples. I'm hoping to finish it today, tomorrow at the latest. Back to Struts ;-) I did a little something so I could test AJAX development with Struts. Basically here is what I do : For the javascript : I get an XMLHttpRequest/ActiveXObject("Microsoft.XMLHTTP") object, on an onclick event. I retrieve the values stored in result.responseText (I don't need XML for the kind of processing I need). I contains something like : label1;value1:label2;value2:label3;value3:... (1) which I split() and process accordingly. On the Struts side : I have an action which does "nothing", except set an attribute for the request with (1) as the output : - MyAction - public ActionForward execute(...) { // retrieve values in the Database ... MyBean result = new MyBean(...); request.setAttribute("result", result.toString()); return mapping.findForward(Constants.OK); } ... and forwards to a JSP which contains the following line : JSP <%@ taglib uri="..." prefix="bean" %> This is working fine AFAIK, but while in IE it displays the result and that is all, in Firefox the page is still in a loading process... even though it has displayed all there was to be displayed ! I don't think this is a problem with Struts, rather with Firefox and its way of handling XMLHttpRequest... But is there a way to bypass this behaviour ? -- Stéphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best practice for "dynamic reloading" of a part of the JSP ?
Hello, Frank W. Zammetti a Ãcrit : > I'm sure what you've found on the net is sufficient, but in case it > isn't, here's a quick example I just threw together: > > http://www.omnytex.com/XMLHTTPRequestExample.htm It seems that you have already removed this example from the web site ... That's a shame, since I hadn't had access to the net until yesterday... Could you please republish it ? Thanks a lot ! -- StÃphane Zuckerman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best practice for "dynamic reloading" of a part of the JSP ?
I would highly recommend using XmlHttpRequest (aka ajax), which is much more user-friendly, much quicker to use and more flexible than reloading the page each time the user clicks on something. This is a solution I wasn't aware of... And it would be a really great one, provided I could find a way to use it in my application. Would you happen to have some code examples I could use to understand better how ajax works ? I found some pretty useful stuff here : http://www.xml.com/pub/a/2005/02/09/xml-http-request.html and there are other papers available that I haven't had time to read, but none with a J2EE example (or even better, a Struts example)... Thanks anyway, that was really useful ! I might not be able to use this technology for this project, but I certainly will for another one ! StÃphane - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Best practice for "dynamic reloading" of a part of the JSP ?
Thanks to both of you, Frank and Erik. I think I'll use a single action with states, as Erik suggested (I had this solution on my mind myself, but I wanted to check whether a better solution existed for my needs). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Best practice for "dynamic reloading" of a part of the JSP ?
Hello, I am to write JSP pages with a form that has some items (lists, or checkboxes) that depend on previous choices from the same form. So here I have two choices basically : 1°) Load all the information that is possibly needed for a given page, hide it, and only show what is relevant with some javascript. For instance, If I select some "foo" option in a list, then below in the form, a second list is loaded with "bar1", "bar2", "bar3é ... options, which are related to the "foo" option. Drawback : if there are lots of possible options, lots of texts, and lots of users, this might be too heavy a solution. 2°) When I select "foo", then some javascript reloads the page (it does a post) with the "foo" argument, and the rest of the JSP is loaded. This is the way I'd like to take, since some informations mustn't be in the clear uselessly. My problem is that I don't really know where to start and how to do such a thing (do I use the same action through different stages ? Or do I put a lot of little actions that lead to a single big one ?) I hope I've been clear enough (I have difficulties finding the right phrases to express my problem), and that someone will be able to help me. Stéphane - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[html:select] Value won't be retrieved by the form ...
Hello, Here is a simple JSP page I set up so I could try to understand the possibilities. My problem is that I do manage to display a correct list extracted from a Collection, but that when I clic on the submit button, the choice is null inside the Action class. Below is the relevant code. Thanks for anyone who could help -- // -- JSP file : [SNIP beginning of the JSP] <% // "debug" object ArrayList list = new ArrayList(); for (int i=0; i < 5; i++) list.add(new LabelValueBean("label " + i, "value " + i)); pageContext.setAttribute("items", list, PageContext.PAGE_SCOPE); %> // SelectAction.java : public class SelectAction extends Action { // simplified Action public ActionForward execute (...) { SelectForm selectForm = (SelectForm) form; if (selectForm.getChoice() != null) return mapping.findForward("ok"); return mapping.findForward("ko"); } } -- Stéphane ZUCKERMAN - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[HTML-TAG] select tag and collections : need of a very simple example
Hello, I am quite new to Struts, but have been playing with this framework for some time now (mostly as a means of understanding the framework)... There is still one thing that isn't clear for me though : I understand how to use a "simple" html:select tag, but when it comes to use a Collection object (such as an ArrayList or a Vector, as these are the objects that are mostly used in tutorials), I am finding myself a little bit confused. I am not sure as to exactly what the attributes of the and refer to. I've already searched through the examples of the distribution, as well as other sites (like jguru), but I really have a problem dealing with select... My use would be something very basic, such as retrieving a list/array of string values (from a database, for instance), and display them as options for my select. I'd first thought of using something like the tag, but I suppose it wouldn't be very coherent with the existence of ... Could someone post a very simple case of how to use the html:options tag ? Thank you very much. Stephane - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]