Re: never ending iterate tag questions
On Sun, 25 Mar 2001, Jim Richards wrote: > > I've now got the tag to work, but I'm confused about how it > works with the collection attribute. I've seen examples for people where they > have > > > ... do something with bean ... > > > but the documentation > > >http://jakarta.apache.org/struts/api/org/apache/struts/taglib/logic/package-summary.html#package_description > > indicates that it should be used thus: > > > ... do something with bean ... > > > The difference here being the "=" inside the scriptlet for the collection attribute. > When I don't have the "=" as the documentation suggests, I get > > Unable to convert a String to java.lang.Object for attribute collectio > > and if I do use the "=", which seem to be the correct way, looking at the generated > Java code, I get the correct response. > It looks like the docs are wrong. The version with the '=' is correct, because you want to use a runtime expression here. Where exactly in the documentation did you see this, so we can fix it? Craig
Re: Iterate Tag question, again --> Short ane sweet
On Sat, 24 Mar 2001, Sundar @eSaravana wrote: > Hi, > > This is my situation: > I have a collection(Vector) of buddyListForm as session attribute. > > So, in my JSP, > > If the Vector you are storing is under session key "buddyListForm", this should really say something like: > > > > > > > > There was a bug several months ago where the "id" bean was not getting exposed correctly, but that has been fixed. How old is the version of Struts you are using? > All I get for this code is: > javax.servlet.jsp.JspException: Cannot find bean buddy in scope null > at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:212) > at > org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java: > . > > I am attaching buddyListForm, too. > > Sundar > Craig
Re: form question
Hey, I had some hard nights fighting with exactly this problem and got a solution wich is not very elegant but works... // some headings for the table <% int i = 0; %> $ <% i++; %> As you see, you use the collektion of your formbean directly. The Bean needs properties, getter and setter Methods according to the Javabean-Spec whats the reason to change BeanItems to beanItems! private Collection beanItems; public Item getBeanItems(int index) public void setBeanItems(int index, Item item) public Item[] getBeanItems() public void setBeanItems(Item[] items) It's also important to configure your formbean with scope="session" in Struts-config and never to destroy your Collection in the reset-Method! The HTML for the input field will show like this: After submit Struts uses the following setter Method: Bean.getBeanItems(0).setAmount("123"); As struts use the getBeanItems(i) Method to get yor Item-Objects, there is no chance to create them in the request-scope. There must be held from the moment you establish your beanItems-Collection for output till the submit of the user in session-scope. Hope that helps Uwe JOEL VOGT schrieb: > Hi all, > > I have a html form on a jsp page. This form has a table generated by the > logic iterate tag. > In each table row, there are two fields, one a checkbox and the other a > text field. > What I want is when the user clicks 'submit' all the values are sent to > an action form for storing and then to my servlet for processing. > How do I make a form that will automatically be populated by all these > values? In other words I'm stuffed please help ;) > > Thanks, Joel. > > Sample jsp: > > > > // some headings for the table > > > > > > > $ > > > > > > > > > > > > How do I get these values into a form then servlet then database?
Re: never ending iterate tag questions
You've found a documentation bug, which I have just submitted to the bug database. As you discovered, you need to use an expression (e.g. <%= value %>) rather than a scriptlet (e.g. <% method(); %>) because the value needs to be returned so that it can be used in the attribute. -- Martin Cooper - Original Message - From: "Jim Richards" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, March 24, 2001 7:14 PM Subject: never ending iterate tag questions > > I've now got the tag to work, but I'm confused about how it > works with the collection attribute. I've seen examples for people where they > have > > > ... do something with bean ... > > > but the documentation > > http://jakarta.apache.org/struts/api/org/apache/struts/taglib/logic/package- summary.html#package_description > > indicates that it should be used thus: > > > ... do something with bean ... > > > The difference here being the "=" inside the scriptlet for the collection attribute. > When I don't have the "=" as the documentation suggests, I get > > Unable to convert a String to java.lang.Object for attribute collectio > > and if I do use the "=", which seem to be the correct way, looking at the generated > Java code, I get the correct response. > > > > > > > -- > Kumera - a new Open Source Content Management System > for small to medium web sites written in Perl and using XML > http://www.cyber4.org/kumera/index.html
never ending iterate tag questions
I've now got the tag to work, but I'm confused about how it works with the collection attribute. I've seen examples for people where they have ... do something with bean ... but the documentation http://jakarta.apache.org/struts/api/org/apache/struts/taglib/logic/package-summary.html#package_description indicates that it should be used thus: ... do something with bean ... The difference here being the "=" inside the scriptlet for the collection attribute. When I don't have the "=" as the documentation suggests, I get Unable to convert a String to java.lang.Object for attribute collectio and if I do use the "=", which seem to be the correct way, looking at the generated Java code, I get the correct response. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Iterate Tag question, again --> Short ane sweet
Hi, This is my situation: I have a collection(Vector) of buddyListForm as session attribute. So, in my JSP, All I get for this code is: javax.servlet.jsp.JspException: Cannot find bean buddy in scope null at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:212) at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java: . I am attaching buddyListForm, too. Sundar - Original Message - From: "Craig R. McClanahan" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Friday, March 23, 2001 2:41 PM Subject: Re: Iterate Tag question, again --> Short ane sweet > > > On Fri, 23 Mar 2001, Sundar @eSaravana wrote: > > > Since nobody seemed to have read my long mail, I am re-writing my mail short > > and probably sweet. > > > > Can I do, multilevel iteration with iterate tag.? > > For example: > > I have collection of beans in my session. In my JSP, I want to first iterate > > at the collection to get the individual beans. And for every bean again > > iterate to get attributes/variables. > > There is no current mechanism to iterate over the properties of a bean > (which is what I *think* you meant by attributes/variables). However, if > your bean had a method that returned all the interesting stuff as a Map or > something like that, you could certainly have a nested iteration over > that. > > For example, consider a bean that has a getter method: > > public Map getProperties(); > > and you had a collection of them called "beans". Then you can: > > > Now processing bean > > Property > has value > > > > > > Any help is deeply appreciated. > > > > Cheers...! > > Sundar > > > > > > Craig > > BuddyListForm.java
init'ing session beans in an Action
I finally have my struts tags working. Next step. My app has jsp pages that populate ActionForms. I now have to populate my entity beans, but one step at a time, so I'm trying to instantiate session beans from my Action classes (which will later operate on the entity beans) and I'm not sure how this is done. I thought that the JNDI init context stuff would go in the init() method of a servlet, but with Actions, not sure if this is correct as I couldnt' override the init() method. Or should my action class be extending from ActionServlet instead of Action? Any help much appreciated.
Re: How to use html:errors ?
Since Struts is a framework, there a number of inter-related parts that work together, the error handling is a good example of that. When you detect an error in your Action, you need a way to display it to the user. Since most Actions are not designed to be "views", this is a problem. Struts solves this problem using four (count'em 4) components, the ActionErrors class, the message resource, the SaveError method, and, finally, the html:errors tag. The ActionErrors class is a way to "log" an error. Rather have you embed a string, the ActionErrors class lets you insert a message resource key. This is the same resource that bean:message tag uses to provide internationalization. The SaveError method puts your ActionError class under a reserved key in the request context, where the html:error tag can find it. In your Action, you would usually have code snippets that look like this: // grab a reference to the application resource collection MessageResources messages = getResources(); // create a error message buffer ActionErrors errors = new ActionErrors(); // process action // detect error if (detect_error) { errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("error.detected")); } // On error, return to input form if (!errors.empty()) { saveErrors(request, errors); // put the error(s) where the htlm:error tag can find them return (new ActionForward(mapping.getInput())); // go home } If the error concerns a particular field on a form, you might also have if (field_error) { errors.add("field name",new ActionError("error.fieldname")); } An important thing to realize is that "error.fieldname" is not what the tag will display. The html:error tag assumes that the strings are the name of a key in your application's message resource, which might look like this ; application.properties errors.header = error.fieldname = Password required error.detected = Database not available error.username = That username was not found errors.footer = For more complex needs, ActionErrors can also use "replacement values" to build customized messages, or to build messages from stock phrases. For more on these classes, see < http://jakarta.apache.org/struts/api > "Suriyanarayanan, Senthil Kumar" wrote: > > How do you make the errors shows up on the generated page.? Here is the code > snapshot.. > > LogonForm.java > public ActionErrors validate(ActionMapping mapping, HttpServletRequest > request) > { > if(password == null || !password.equals("password")) > { > ActionErrors aes = new ActionErrors(); > ActionError ae = new ActionError("Please type the > valid password"); > aes.add("?", ae); > return aes; > } > return null; > } > What should I put at the place of '?' in the above add method > > struts-config.xml > > > > > > > > type="package.LogonAction" >scope="request" >name="logonForm" >validate="true" >input="/logon.jsp"> > > > > > logon.jsp > > > > UserId: redisplay="false" /> > Password: maxlength="16" redisplay="false" /> > > > > I saw one of the postings talking about saveErrors method. It belongs to > Action Object, and I how do > I get reference to action object from the validate method? > > Thanks in advance, > Senthil Kumar.S
form question
Hi all, I have a html form on a jsp page. This form has a table generated by the logic iterate tag. In each table row, there are two fields, one a checkbox and the other a text field. What I want is when the user clicks 'submit' all the values are sent to an action form for storing and then to my servlet for processing. How do I make a form that will automatically be populated by all these values? In other words I'm stuffed please help ;) Thanks, Joel. Sample jsp: // some headings for the table $ How do I get these values into a form then servlet then database?
RE: WebSphere 3.5.3 problem
FWIW, the SYSTEM DTD issue is a twofold problem: a) The classloader returns a null for the URL provided b) Struts doesn't check a null for the inputstream. One of these days, I'll send a patch in for b) I'll try a simple app to test the getResource* issues, and file a PMR, early next week. -- dIon Gillard, Multitask Consulting Work: http://www.multitask.com.au NetRexx: http://www.multitask.com.au/NetRexx.nsf - Forwarded by dIon Gillard/Multitask Consulting/AU on 24/03/2001 07:42 PM - RE: WebSphere 3.5.3 problem > I did our 3.5.3 installation yesterday and it was as per > 3.5.2. I still > needed the changed action servlet and also a change of the > struts-config.xml to use a SYSTEM DTD rather than a PUBLIC one. > > It did NOT work out of the box. getResourceAsStream still > appears to be > broken in 3.5.3 How odd, because I am 100% sure that the getResourceAsStream works fine for us in 3.5.3! We used to have a patch for it when running 3.5.2, but all of us removed that patch when we upgraded, and it still works. I believe that we are using a system DTD though, but not because it didn't work otherwise. Oh, and we're running the advanced version of WAS. On the other hand, I'm not too surprised since we are experiencing strange behaviours with WebSphere every day. I sincerely think that just about any other application server out there must beat WebSphere in terms of productivity and ease of development. Is there anyone out there that has positive experiences from WebShpere? /Markus Previous Document Next Document Return to View
Actions and Session Beans
I've finally got struts taglibs and a few Actions working in my jsp pages, but I'd like to be able to populate some EJB's with the model data from the ActionForms. I'm not sure how to do this. I've got a session bean which operates on an entity bean which I will then send to another machines java app, but I'm not sure how to implement the session bean in my Action. Anyone know of examples or where I may find some refs on doing this?