Conflicts between two hooks modifying the same jsp file - java

I saw here some questions with the same topic as mine, but they are quite old. Is there maybe nowadays a working solution? Something that makes an automatic merge of the two hooks and wont destroy the default jsp?
For people who dont know what my problem is. When you deploy two hooks on the same .jsp file, the original jsp is being deleted. And im looking for a solution which makes an merge of the two hooks and the original wont be deleted.
Thanks

There's no concept of automatically merging two different JSPs - it would only work in few cases and leave others open to the same problem.
The code that Pankajkumar Kathiriya links in the comment (my blog article) solves this problem by denying the deployment of the second hook. You'll then have to merge/resolve the conflict yourself.
Some version of Liferay (maybe the latest 6.2 CE GA) implements it as well - the blog article links to the issue. Note that Liferay's own implementation doesn't give you the full logging information that my implementation gives you, but it works. There's also an extension that also includes duplicate overridden struts actions.

Related

Is There a Glossary for each Liferay JSP?

Asked on Liferay Forums - post
I'm creating a Hook on top of Liferay's Doucment and Media Portlet to extend the original JSP. Extending the JSPs are straightforward, but I have no idea what they might be called. Sure I can guess but who wants to do that? In particular, I want to add an additional menu item on Document and Media's > Document > Edit Dropdown Menu
Does Liferay provide a glossary or index on where I could find this and any other JSPs I might extend?
Simple answer: No.
While JSPs are easy to overload, there's no API involved and technically you're in the implementation and not the API. Thus there's no assumption about good maintainability, no promise for stability and no API-style documentation at all.
I'm aware that JSPs are popular to overload, but they're actually dangerous and must be used with care.
You will have to view source for this kind of modification. But as soon as you realize that you're hitting the implementation, it all makes sense (and you don't really want to overload them any more)
Here's an answer I got from another member on the forums:
Hey Clay,
There is no "glossary" per say (at least not one that I am aware of)
but once you understand the pattern that LR uses it can be pretty
straight forward. First things first, if you don't already have it in
place, make sure you download the source for the version of the portal
that you are using.
under the portal-web module you will find /html/portlet. This is where
all the views for the Liferay portlets are stored. Most of them are
pretty straight forward. For example, doucment_library in your case.
The other thing you want to look at is the struts-config.xml file
(portal-web/WEB-INF). In that file you can search for "documents" and
you will find all sorts of documents and media references. What you
are interested in, for example, is something like this I think --
1 <forward name="portlet.users_admin.edit_organizationpath="portlet.directory.view_organization" />
The "path" attributes are references to the jsp files. So in this
case, /html/portlet/directory/view_organization.jsp -- /html being
implicit for these paths. I often reference this file to understand
where the struts actions for things in the control panel go.
So, no "one pager" with all the details, but once you understand the
pattern (which is super basic) it's easy peasy to get around.
Hope this helps!

Multiple language support in Spring project without using multiple message_language.properties files

I want to add different languages support in my Spring Web-MVC application without adding message_language.properties file for each language.
But I found message_language.properties file solution everywhere.
I searched deeply but I haven't got any solution for it.
please suggest me any solution....
Its not clear what are the reasons why you search for a different solution. Perhaps not what you want, but many projects that require dynamic language addition use database backed resource bundles (technically speaking its the solution without the properties file, but essentially the approach is the same).
If this is what you want you can check out the blog http://www.webreference.com/programming/Globalize-Web-Applications15_Java_ResourceBundles/index.html.
The following stackoverflow could be helpful as well
Database backed i18n for java web-app

Is it possible to make Class.forName("") flexible?

before asking, please understand that my english is not good.
I'm using Class.forName(...) class in a servlet programming. when I access the servlet, I get a row of detailed controller information from Database indicating which controller to use.
This is Class.forName(...) I coded:
Class c = Class.forName(row.getControllerInfo);
c.newInstance();
This works fine, but there's a problem, i'm using Eclipse. The problem is that when I modified the Controller file, the changed contents were not applied to the server.,,.
Probably the easiest way is not to support dynamic loading. Much better to achieve something like dynamic update by supporting multiple servers. For development, you could get around redeploy delays by using JRebel (there might be others).
If you really do want dynamic loading of classes then the answer is "class loaders". I suggest having a look at those, and come back with any specific questions.
If I understood your problem true,
When you change any file of your project, you must deploy your project to server. If you use server from eclipse, republish may solve your problem.
have you tried clean - re-built and then deploying your application?

Struts 1.2 validation question

I am validating my login form. I have created a validation.xml, added the plugin in struts-config.xml, created ApplicationResource.properties file etc. I have done all the necessary things for validation frame work, my application is also running without errors but it is not validating the data. I have rechecked many times. Please anyone tell me where should I check for probable errors.
Thanks
If as you say, the application is running without errors and your data is not validated, then I think that the validator plugin isn't picked up by your application. That could occur if your login form is not extending ValidatorForm but your plain ActionForm. Are you extending ValidatorForm?
Recheck your code against a Struts validator guide. Even if you already did that, there is still something you might have missed or misunderstood.
Have a colleague or friend look at it. Someone with a fresh clean perspective might notice something you missed because you stared to long at your own code.
If that is not possible you can always delete everything (that is to be read as: save current solution somewhere then get a clean copy from source control) and start from scratch. If then it works, you can compare with what you saved from your initial solution and spot the difference.

How to test JSP TagExtraInfo?

I consistently have troubles getting my TagExtraInfo implementations to work properly. I have one implementation that works, and one that doesn't and I unable to see the difference between the two. And all the IDE's seem to have have "bugs/features" regarding this, which makes it hard to see where the problem actually is.
The relationship between a TagExtraInfo and a jsp tag should be reasonably well-defined, and I assuming I should be able to get some kind of compliance-testing software. Anyone know anything like this ?
You can use Jetty. That is a simple web container that can be started from your unit test. You can prepare a simple web.xml, test.jsp and monitor exceptions in order to see if everything works fine. There is an interesting article.

Categories

Resources