Win a copy of Spring Boot in Practice this week in the Spring forum!

dave sag

Ranch Hand
+ Follow
since Feb 17, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by dave sag

Originally posted by Jim Yingst:
I don't know what kind of server you're dealing with here, but it probably has some sort of shutdown method. Find that, and see if you can insert a close() call to the file as part of the shutdown sequence. Alternately if you normally shut down using control-C or something, you can try using a shutdown hook:

This can't always be guaranteed to work, depending on shutdown method (e.g. kill -9 probably won't bother respect the shutdown hook, I'm guessing) but it's as good as you're likely to be able to get on most systems.



I have found that this works fine for code executed directly but if you try running it using ant's java task then crtl-c never invokes the shutdown hook. I have written a simple test that shows this is true. not sure if this is a bug in the JVM or Ant's Java task.
17 years ago
We have implemented a quite comprehensive customer support system using JSF as an in-house prototype of the JSF technology. We have not been able to come up with a satisfactory solution to the following problem however, and have been unable to find any examples code that addresses this very common situation.

we need to allow admin users to edit company details.

we provide a ListCompanies page that gives a list of the company names and the user then clicks on a name to edit that specific company. we use a command link with the company id being passed as a key. when the company has been edited we return the user to the list. this you would think would be a very very common situation and quite trivial. it is not however.

The ListCompanies page is backed by a request scope ManagedBean that provides a sorted list of the companies. the EditCompany page is backed by a request scope CompanyHandler. the company handler checks the request parameter and loads a CompanyBean that then backs the edit company form. the company handler has a managed property which is the actual company bean.

this all seems too complex but if we don't jump through these hoops we get stuck in the following situations:

1) if we just have a request scope bean for the edit company form then any validation errors cause a new request and we lost the contents of the bean and the request parameter containing the id of the company to edit and the form ends up blank.

2) if we use a request scope managed bean for the edit company form then we get the same company every time we try to edit from the list becase the jsf framework only creates one bean per session.

so the solution was to have a managed bean that works out whether it needs to use an existing bean or create a new once for the form. this seems like a cludge and a crazy amount of over-engineering for such a common problem.

also we are getting issues with our users clicking on the browser's back and forth buttons and causing strange things to happen to the forms.

We feel this is such a common problem there must be a generioc solution to it, but so far all searching has been for naught. Does anyone have a pattern they have used for this sort of scenario?

Thanks in advance

dave
18 years ago
Hi, I am by no means a newbie now with JSF but have hit this strange and very newbie type issue. Our web app was working fine and then, with seemingly no changes, we are getting the above NoClassDefFoundError looking for javax/faces/context/ExternalContext


now clearly tomcat (5.0.19) is loading the javax.faces stuff as further down the stack trace there are javax.faces.webapp.UIComponent classes being loaded okay. we have ensured there are no jar file conflicts, etc etc but just can't get past this issue. anyone else had this issue and able to suggest a solution?

dave
18 years ago
We need to create a multi-page form using JSF. If we give out backing bean 'session' scope then when the user back out of the form altogether to say a list of users to edit, and click on another suer to edit, because the backing bean is sessions cope it is never recreated and so we just get the smae values over and over. if we set the bean to request scope then of course it vanishes but the form can't continue.
this seems to be a very generic problem and none of the examples show anything more complex than a simple edit of a single item so are not much help. what are other JSF people doing to solve this issue?
18 years ago
We are migrating a small inhouse webapp from struts to JSF and would realy benefit from some unit testing of the kind offered by StrustTestCase. I have googled a bit but with no luck so far - what are JSF users using to unit test their managed beans?
18 years ago
We are migrating a small inhouse webapp from struts to JSF and would realy benefit from some unit testing of the kind offered by StrustTestCase. I have googled a bit but with no luck so far - what are JSF users using to unit test their managed beans?
18 years ago
JSP

Originally posted by Hans Bergsten:
I'll try to answer both questions here.

JSF is great for complex user interfaces, i.e., for web applications that look and feel as much as a GUI app as possible. For such an application, JSF boost productivity and reduces complexity.
<< snip >>
.



We are developing a suite of web applications and using JSF (and JDO) to do it, even though the initial site we are doing is a full migration from Struts (and Hibernate). We went through a serious learnign curve and still are crawling - the site would have been sone a week ago if we used the old code but we were given the green light to migrate and it's been awesome. the amount of actual code you need to write is much less with JSF than struts, but there are some limitations we have not puzzled over enough yet. the mixing of JSF and tiles is a challenge and there is too mcuh of this ugly <f:verbatim> stuff in the final JSP, but perhaps we are approaching it wrong.

still we are happy to have made the leap and feel that we have built a good baseline for a best - practice web app.
18 years ago
We have designed our site to be xhtml strict and are using CSS rather than tables to manage positional layouts, and so forth but would like to generate DIV and SPAN tags as appropriate for overal page positioning rather than tables. wer could add our own tag, component, renderers etc, for a layoutPanel for example, as distinct from a gridPanel but that seems like overkill. I am honoured to have the opportunity to pose this question to you. your input is appreciated.

dave
18 years ago
Hi there. My servlet needs a reliable way of determining it's base path, ie the path to its folder in tomcat's webapp directory. is there a simple, container independent way of doing this?
18 years ago

Originally posted by dave sag:
From looking in the Struts1.1 source code at It does appear that it is valid to specify a 'name' param in your Action configuration in struts-config.xml without specifying an actual form, and thus you can use the name to tie actions and forms together in this manner.


needless to say I did not look hard enough. if you specify a 'name' the Struts controller assumes there is a form associated with that page and throws a wobbly.
so use the parameter instead and if already using it, like I am then I guess it's just a matter of formalizing your parameters. in my case

will need to become

doh. I'll post to this thread again when I have a proper working example of this. anyone interested in seeing the generica package i am developing should check out
the JavaDocs.
18 years ago
I am interested in this very problem and have been thinking about how best to deal with it in a fairly generic manner.
All of my actions follow the pattern described above whereby the call to action invokes a FormAction that loads whatever i need into the request and then passes control to the jsp (or tile in my case) which holds the form UI components. pressing submit calls a handler action. of course any failed validations will bounce back to the first action, reload the data and repopulate the form. because the two events exist in separate requests it has seemed that the only logical place to put data common to both requests is in the session. I find this solution less than satisfactory however as it then becomes the responsibility of the final handler action to clean up any temporary cruft left in the session.
also this is problematic in cases where you may be wishing to implement multi-page forms.
the solution I am considering is inventing a new pseudo-scope, called 'pipe' that functions exactly as a session, except it is opened by the first action and ultimately closed by the final action. the pipe is a form specific singleton, ie there is one pipe per form-name.
A new Pipe would be created (or optained) via

and then attributes can be set and get just like a session or request.

and finally a pipe can be closed

actions (in their execute method) and forms (in their reset method), mid-pipe, can simply get the pipe for that form by calling

internally the pipe is simply a trimmed down interface similar to the standard HttpSession interface with an inner Factory class to handle the building and gathering.

From looking in the Struts1.1 source code at It does appear that it is valid to specify a 'name' param in your Action configuration in struts-config.xml without specifying an actual form, and thus you can use the name to tie actions and forms together in this manner.
Can anyone see any significant problems with this approach?
dave
18 years ago
I want to use the logic tags to decide which style sheet to use based on the user's user-agent. does anyone have an example of this?
19 years ago
My JSP page complains that "No getter method for property lostSensitiveDataEntry[0].value" when very clearly in my form bean (whcih extends DynaValidatorForm) I have the method:

and in my struts-xml file i have specified that "lostSensitiveData" is a List and that list has been populated in my reset method fine.
this is almost the exact same code as in other forms I use, only this time, as there are lots of other properties too, I am using a DynaValidatorForm and not an ActionForm. I have even tried extending DynaValidatorActionForm instead but it made no difference.
What am I missing, or is this a bug in struts?
19 years ago
Currently my site uses tiles extensively, but I can not decide what is the best to use for the following case:
I have a simple login-form. It needs to appear on 3 different pages, and is identical on each of them. my login form bean looks for a user bean in the request and if it finds one prepopulates the username field.
usign tiles to insert an ad-hoc login form seems like overkill, but is probably the cleanest way to do it.
using template:insert to do this is confusing - i have read and reread the template docs and they make no sense to me and I can't find any decent examples. (are the files i am including served up through the webserver or can i just specify a local path to them - ala tiles?) can use the forwards i have defined in my struts-config?
using jsp:include to do this means i need to expose the exact path (or are these included via the server too?) and i am not sure whether things I include will trigger calls to my form bean properly or not.
all a bit confused here. what do other people do for small reusable struts forms? got any example code you'd care to share?
19 years ago
The Struts bean:write tag allows a format string to be used to format the data it is writing. I want to format a date ala java.text.DateFormat.LONG
how can I do this using either the format or formatKey attributes of the bean:write tag?
19 years ago