Colin Freas

Greenhorn
+ Follow
since Aug 11, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Colin Freas

David Newton wrote:

Colin Freas wrote:... Servlets, JSP, Beans, Struts, and Tiles.


Not really, except maybe for beans. None of the other things there are "convention" by default, unless you count wildcarding.



No, really. There's convention in all those things, both explicit and implicit, disregarding completely the straw-man of wildcarding. Taglibs in JSP, by convention, have standard prefixes: html, c, etc. Beans use get, set, and is for method names. Servlets can be accessed with .../servlet/... in the URL.

David Newton wrote:

Colin Freas wrote:And style sheets exclusively affect the view, thus they belong with the JSP - however it's created.


Unless, of course, the requirement demands something else. Tiles was created to allow configuration of view-side properties (a) outside of Java code, and (b) outside of the JSP. Things like stylesheets, for example.



I said 'belong with the JSP - however it's created.' Tiles has a part in the creation of the JSP. In a previous post you said

David Newton wrote:...the JSP isn't the greatest common denominator, the action is...

I was responding to the implication of your assertion that relying on the action name is a better idea.

David Newton wrote:

Colin Freas wrote:Either way, I don't believe the motivation for the creation of software should restrict it's use.


You are responding to something that was never said; perhaps you got your threads confused.



No, I'm responding to where you wrote:

David Newton wrote:...that's the kind of problem Tiles was created to avoid...




David Newton wrote:

Colin Freas wrote:And whatever that motivation I'll say this: I generally expect request.getRequestURL() to return the URL I see in the browser.


That's an unreasonable assumption, particularly when including dynamically including resources, and can be container-dependent.



Ok.


David Newton wrote:

Colin Freas wrote:
I put an attribute into my tiles-def.xml file, "customStyleSheet", and gave the attribute a default "" in the master definition.

But this results in a <link> with an href of something like "/app/styles/" without a filename. Doesn't seem to break anything, and I could put in a zero byte default file, but is there some way to suppress the rendering of that <link> if <tiles:getAsString name="customStyleSheet"/> is zero length?


Sure; check to see if it has a value.



So, you know what, whatever.

If you know how to make this happen, share the knowledge, because I didn't have the time to figure it out last week, and I don't have the time to this week. So I put in a mechanism to specify an explicit css page for each Tile def.

If you don't know, then ok, that makes two of us, and you've made it clear you have a negative opinion about what I'm trying to do and the way I'm trying to do it, and you don't see why it would be a good idea. So, ok.

Either way, thanks for the idea to check for the value. Duh (to me, not to you.) That ties up the last loose end, and I won't have <link>'s to nowhere now.
14 years ago


Convention over code: a notion underlying many aspects of Servlets, JSP, Beans, Struts, and Tiles. And style sheets exclusively affect the view, thus they belong with the JSP - however it's created.

I don't know enough about Tiles to speak to the motivation for its creation. Seems like pretty straightforward code reuse to me. Either way, I don't believe the motivation for the creation of software should restrict it's use. And whatever that motivation I'll say this: I generally expect request.getRequestURL() to return the URL I see in the browser.

Anyway...

I put an attribute into my tiles-def.xml file, "customStyleSheet", and gave the attribute a default "" in the master definition.

But this results in a <link> with an href of something like "/app/styles/" without a filename. Doesn't seem to break anything, and I could put in a zero byte default file, but is there some way to suppress the rendering of that <link> if <tiles:getAsString name="customStyleSheet"/> is zero length?
14 years ago


Working on a large Struts 1 app with Tiles, so my first thought is to use Tiles. That said, I'm more than happy to consider an alternative that achieves the same effect another way.

What I want to do is include a <link> to a style sheet based (preferrably) on jsp name.

Right now we have an app wide style sheet, which I need to override in certain places.

What I'd like to do is include in my WEB-INF/jsp/widgetPage/ directory a .css file that will automatically be included, based on the jsp name. For instance, WEB-INF/jsp/widgetPage/bodyWidgetPage.jsp will know to include WEB-INF/jsp/widgetPage/bodyWidgetPage.css. I'm not sure I can do this because of protections on the .../jsp/ directory, but I'd settle for something like WEB-INF/css/bodyWidgetPage.css.

As I say, we're using Tiles, so ideally, I would put something like this into the master tile definiton:
<put name="customHeaders" value="/WEB-INF/jsp/layouts/customHeaders.jsp" />

That .jsp would be something like:
<% // process request.getRequestUrl() to point to css based on naming convention %>
<link rel="stylesheet" href="<%=processedCssUrl%>" type="text/css">

And then the main layout .jsp would be something like:
...
<head>
...
<tiles:include attribute="customHeaders"/>
...
</head>
...

The implementation above doesn't work for me though, because request.getRequestURL() in my proposed customHeaders.jsp will display the URL to the main layout page, not to the jsp whose name I'm interested in parsing to find the custom style sheet.

Any thoughts, insights, and ideas greatly appreciated.

-Colin Freas
14 years ago

Thanks for the replies, gents. btw: Struts 1.

So, I'm trying to figure out the Struts-iest way of doing what I'm doing.

I have a page with some charts on it. I have the action, the form, and the jsp for the page containing the charts. The charts themselves are images and html image maps generated by JFreeChart. So, I need the image map markup included in the jsp, and I need the binary image data in the response to the request from the <img> src attributes.

For argument's sake, let's say I don't want to have the forward to the servlet as Ankit suggest. I see how this is a completely viable solution, but this is the only point in the application where that technique would be used, which could make for maintenance problems later.

So, thinking about this, I wondered if the following makes sense, vis-a-vis the Struts MVC paradigm. I put the methods that generate the binary image data into the form class. The chart action then calls those methods, and overrides the normal response, when a parameter is set in the request.

So... does that make sense? Is that the Struts-iest way to do this?

-Colin
15 years ago

Referring to section 3.5.1 of this page: http://struts.apache.org/1.x/userGuide/building_view.html

That talks about using a servlet to render binary image data.

Right now, I have my binary image data being written in a JSP, which is sort of fine.

But I'd rather do this in a servlet, because the JSP markup is useless here.

How do I set that up? Is there some magic in struts.xml? Do I need to play with the controller?

All help appreciated,
Colin Freas

15 years ago

I'm working on a jsp page which contains several expressions like this:
    @{bean.widgetProperty}    [at brace bean dot widgetProperty]

Is the @{bean... notation part of the JSP specification? Is that part of the JSTL?

We're also using Common Controls, a third-party library for interface design, but it's documentation is lacking, and I wasn't able to find reference to this kind of notation.

Thanks for any assitance.

-Colin Freas

[braced comments only for easy searching]
15 years ago
JSP