I have this main page main.jsp in wich i want to s:include dataParams.jsp page, and togheter they render as one.
The problem is that dataParams.jsp uses some data from the database and i want to fetch that in the DataParams.class that extends ActionSupport that gets the data from a DAO.
How can i retrieve the data (an int) and passing as a param using something like this? lineCount is the int field of DataParams action class that backs dataParams.jsp but obviously i can't s:include an action, so what are my options?
Should i just call the DAO in the included jsp? Or can it still be done with a mapping?
I'd re-architect. You'd doing logic that should be on the Java side in the JSP. Keep your JSPs as "stupid" as possible.
Joined: Nov 29, 2009
The Java side is either struts 2's actions, or servlets, which means going back to struts 1. Theoretically a s:include should process an action since th sLinclude returns only the rendered page (supposedly) - and that would clear all this problem up.
I think for pages that only use a minimum of database interaction i could use JSTL sql, and for heavy parameter pages and logic, a dispatcher servlet with a DAO respectively.
I rather do it struts 2 style if i'm using struts 2 though.
I am not the first to say it, in fact someone quite experimented in Java said it.
Besides that i read a lot on a lot of frameworks (for my level of experience).
In comparison to others, Struts 2 documentation is weak.
For instance i got the solution for this off someone's post or maillist, not from the documentation itself.
I even saw people complain about support from devs, although i don't ask for myself, i recognise that that will attract more developers to one or another framework.
Nothing personal though, i will still use it, i think it's an improvement over Struts 1. Unless i come upon a major downside... i hope not.
For example's sake, MSDN is the most comprehensive documentation there is (MS capital show off), too bad it's targeted mainly at the MS platforms.
Javadoc is good, although i pulled of examples from other sites more than i did with .NET
What i think Struts 2 should do is be more exhaustive on the subject and treat everything nuts and bolts style.
For example i would've espected to see the action tag's result sub-tag somewhere under configuration, not in result types. The definition - demonstration (example) pattern seems to always work, so it should always be used, exhaustively and right on the point, to not leave room to any ambiguities.
For example i would've espected to see the action tag's result sub-tag somewhere under configuration, not in result types.
I beg to differ here, all the configuration elements are covered at together. That page has all the struts configuration elements.
I generally need struts tag reference to look up tag attributes. If you look at how many tutorials and references they have here, then I think its pretty good. And MS has their billions of dollars, still what apache is doing with collaborative efforts from individuals is pretty good. People pay for MS products, they have to have good documentation. Still MS doesn't have a good API reference like javadocs...
Joined: Nov 29, 2009
Maybe i've been spoiled
I have the habit of glancing over the data searching for patterns i'm already used to, so i might miss a hyperlink if it's not the first thing it hits me when i'm glancing the documentation. Practically i espect to see only something like this in a config doc (with relevant design):
element list (short description) >
element (full pseudo/meta arrangement like the full description of a SQL command) >
full description (attr list (short description > full description with example)
also see: related functionality, guides, primers, cookbooks, etc
pretty much javadoc or MSDN
For me the experience has been less than usual, so i missed the result types the first time, got boggled reading about and got my answer in a chat room where i was pointed out. Also got boggled trying to use the old way to access the params, doc makers had bigger problems perhaps and forgot to add a direct example for us newbs (glancing about i couldn't make the relations - that's why direct examples of usual problems help a lot). I'm using pretty much everything you pointed at now, just that it's not always as easy as i espected to find one or two things, otherwise is good.
If you're on the Struts 2 page, follow the Getting Started link. Or skip a step and jump from the S2 home page directly to the Tutorials, where the first links are to a bootstrap example and a full S2/Spring2/JPA/AJAX example. It doesn't get a *whole* lot simpler than that.
The Guides page has what you'd expect: links to information about what every major component is, how it works, default configurations, and so on.
Considering how much you're paying for it I'd say you're getting a pretty good deal. Feel free to file a CLA and contribute more to the documentation--make the improvements you want. That's the beauty of open source. And its curse: it depends on the generosity, hard work, and time of "other" people, who do the work because they want to or use it themselves.
Again i would've espected that as an example directly in the OGNL guide or in the HelloWorld example for people to stumble upon. I'm not complaining about the whole documentation, just the issues i had with it and described. Also i don't search the link to give feedback because there's a high chance the effort would be wasted, only thing that ussually matters to programmers is getting their work and only theirs in there (ussually not generally). Criticism is not welcome. Although best kind of feedback is the forums, gives a good ideea what people are dealing with and provides answers as well.
Couldn't struts 2 devs evaluate the parameter name itself key versus values behind the scenes if it's a map? How would i know what index is a certain value in the same parameter map? In the end the user would have to do it with getParameterValues().
If i get a job using struts 2 i'll have the resources at hand to contribute (time and money), otherwise i don't deal/negociate with capitalism if i can.
Well, you're welcome for working on it even though I have a job that doesn't use it, then--money isn't a prime motivator for me, either. If it was, I wouldn't spend so much time on here answering people's questions, and listening to their criticism, for free.
It wouldn't make any sense to put that example in OGNL, since it's not an issue with OGNL. I don't believe the Hello, World example uses an include (and the point of Hello, World is to be simple: not to introduce edge cases. Even if it *does* use an include, that wouldn't be the appropriate place to add this information).
If you don't bother reporting documentation errors, then you shouldn't be surprised that the errors aren't found. I don't know how you expect to get the changes you seem to want if you're completely unwilling to provide even the modest input of providing feedback. Seems like you just want to take, without giving anything back, but perhaps I've just misunderstood you.
Found how to post a comment, dunno about JIRA yet.
I said reference the OGNL documentation not reproduce
Also i would find it useful if i could post changes myself, i wrote documentation at my old workplace.
I find referencing the source useful for a number of reasons:
- people find it usefull to get info at the exact place they espect it to;
- referencing a link increases page rank as far as i know;
- through observation on the problems of people in forum, further examples can be added in the struts 2 documentation bundle, that complement OGNL (as long as it has an OGNL section).
I can find it motivating for two reasons:
- i would see the change get done (and not feel like doing something idle);
- i could mention i'm a struts 2 documentation contributor at a job interview (and increase the buzzness of my CV ).
Lastly i could upload the documentation i did as a sample, so how do i sign up as a contributor, please?