I want to add a new java class to DSpace. I've followed this link for adding a static page. I made all the necessary changes. After rebuilding the package and running ant update, I'm still not being able to see any change.
I checked my dspace installation directory, and found that the class added by me in not there in it.
It would be very helpful if I find a tutorial which explains step by step how to incorporate a new java class in DSpace 4.2. Could someone help me out or share some useful links. Thanks in advance.
I used the cocoon based method.These are the steps which I followed:
I created a java file TestPage.java in [dspace-src]/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/.
Then I made changes to the sitemap as specified in the instructions in the link in [dspace-src]/dspace-xmlui/src/main/resources/aspects/Discovery.
I added this under <map:transformers>
<map:transformer name="TestPage" src="org.dspace.app.xmlui.aspect.discovery.TestPage" />
This was added under <map:pipelines>
<map:pipeline>
<map:match pattern="test">
<map:transform type="TestPage"/>
<map:serialize type="xml" />
</map:match>
And finally I changed page-structure.xsl to include a link to the new page which I created, within <xsl:template match="dri:body">
<a>
<xsl:attribute name="href">
<xsl:value-of select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[#element='contextPath'][not(#qualifier)]"/>
<xsl:text>/test</xsl:text>
</xsl:attribute>
<i18n:text>Test</i18n:text>
</a><br/>
Unfortunately, the instructions you were using are out of date for DSpace 4.2. The directory structure has changed. You will need to put your file into [dspace-src]/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/ instead.
The rest of your approach should be fine (at a cursory glance).
Related
(FYI this is version 1.4, and yes I'm flushing my var/cache folder. I've started reading through Alan Storm's tutorials and that helped, but nothing specific on this problem)
I am new to Magento, we are using the OnePage checkout method, and we have the following:
app/code/local/Ourcompany/Checkout/etc/config.xml
Which has the following definition:
<frontend>
<routers>
<checkout>
<args>
<modules>
<Ourcompany_Checkout before="Mage_Checkout">Ourcompany_Checkout</Ourcompany_Checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>
I have a corresponding file in:
/app/code/local/Ourcompany/Checkout/controllers/OnepageController.php
In there I have a class:
class Ourcompany_Checkout_OnepageController extends Mage_Checkout_OnepageController
So far I have not been able to get Magento to acknowledge it's there. The native methods in core are being called only. If I remove or rename this page, there is no error statement - I think my syntax in config.xml is not correct. Can anyone identify the improper syntax present?
This is the first time I have answered my own question but I think the answer here is noteworthy. The CommerceBug debugger was very useful as I was able to look at classes that were loaded. As it turns out, there was another module that had been created, called Admaster which got precedence as the router for the OnepageController.
I'm sure dealing with this type of conflict is common for Magento, so I have a mental checklist item now if this happens again.
I currently have a package on my class path called MyResources with multiple property files that struts uses. Works great:
<constant name="struts.custom.i18n.resources" value="com.company.MyResources"/>
I am trying to move the properties files to a file location, so they can be updated without having to rebuild the package. Is it possible in Struts 2 to refer to this file location?
For example, my new file location with the properties files is:
/g01/properties/
And I would like Struts to use that location for the resource.
Yes, by providing an implementation of ResourceBundleTextProvider and initializing it in your struts.xml configuration file.
The default implementation, com.opensymphony.xwork2.TextProviderSupport defers the text lookup to com.opensymphony.xwork2.util.LocalizedTextUtil.
There are a number of ways to go about this, but if you don't need any of the default S2 behavior, here's the place to start:
<bean type="com.opensymphony.xwork2.TextProvider" name="struts"
class="com.opensymphony.xwork2.TextProviderSupport" scope="default" />
Provide your own ResourceBundleTextProvider implementation that uses whatever configuration management you want, for example, we implemented a DB-backed version (with caching, of course) that allowed translations to live in, and be managed by, a normal DB and I18N front end.
I'll see if I can dig up my original work this weekend and provide a link to a stripped-down solution.
The location of the file cannot be off the class path when you run your app. You should determine which classloader is used to load the resource. Then you should find a way to configure this classloader to be able to use the location as resource. So, it's possible. A short answer.
I am using JSR 303 Bean validation in my JSF 2.0 web application and it works fine with annotations. Now I would like to ignore annotations and configure validation rules using the validation.xml file, so this is what I did (I am using an eclipse dynamic web project) :
Added validation.xml under WebContent/META-INF/validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd"
>
<constraint-mapping>META-INF/validation/constraint-mapping.xml</constraint-mapping>
</validation-config>
Then created the file constraint-mapping.xml under WebContent/META-INF/validation/constraint-mapping.xml
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<bean class="my.full.path.ValidationMB" ignore-annotations="true">
</bean>
</constraint-mappings>
Having these configurations in place, I suppose the annotations in my bean class ValidationMB shall be ignored, BUT this is not happening!, which makes me assume that the validation.xml file is not being loaded.
any ideas? thanks.
Environment:
Apache Tomcat 7.0.23
javax.faces-2.1.4.jar
hibernate-validator-4.2.0.Final.jar
hibernate-validator-annotation-processor-4.2.0.Final.jar
validation-api-1.0.0.GA.jar
slf4j-api-1.6.1.jar
From the spec: section 4.4.6. XML Configuration: META-INF/validation.xml
Unless explicitly ignored by calling
Configuration.ignoreXMLConfiguration(), a Configuration takes into
account the configuration available in META-INF/validation.xml. This
configuration file is optional but can be used by applications to
refine some of the Bean Validation behavior. If more than one
META-INF/validation.xml file is found in the classpath, a
ValidationException is raised.
To solve my problem I had to create a META-INF folder under the project src folder, which ends in the WEB-INF/classes/META-INF.
The structure of the web application is:
ROOT
|_META-INF -- don't put validation.xml here
|_WEB-INF
|__ classes
|_META-INF
|__validation.xml
But I think that if I pack my web application in a jar file and reuse it in another project It may not work, I will let you know later once I do it.
Try to put your validation.xml directly into the WEB-INF/ directory.
I stumbled across this while looking for something else but wanted to clarify to the OP what is happening. You do in fact need the file to exist at META-INF/validation.xml; however, that is relative to the classpath which is why it worked when you put it under WEB-INF/classes/META-INF/validation.xml.
The cleaner approach is to let the file be put there for you. Your Eclipse project should already be outputting whatever is in your source directory to WEB-INF/classes somehow for you or nothing would be running. But sometimes there are filters on what it outputs so it might excluding something. You might want to check your src dirs and make sure they don't have exclusions.
Just as an example, if you had a Maven war project, all of your java sources would go in src/main/java and the generated classes would end up in the WEB-INF/classes directory. The equivalent happens for src/main/resources which contains non-source files. When I want *.xml, *.properties, etc. to end up in WEB-INF/classes I put them in src/main/resources. For your example I would have a src/main/resources/META-INF/validation.xml file.
Hope this helps anyone else who comes across this and is confused.
In a Struts 2 based project, one of the jar files i am using is struts2-core-2.0.14.jar, and when i removed this jar and replaced this with struts2-core-2.1.8.1.jar the application fails to start.
Most Probable, as far as i understand, the problem is with the filter class declared in web.xml
For the version of struts2.0.x,The class "org.apache.struts2.dispatcher.FilterDispatcher" is used as filter.
For the version of struts2.1.x,The class "org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter" is used as filter.
For more inform, please refer
http://www.mkyong.com/struts2/difference-between-struts-2-filterdispatcher-and-strutsprepareandexecutefilter/
I got a question about applying custom itemstyle.xsl to CQWP.
I extracted existing CQWP, renamed it, and uploaded to webpart gallery on a site collection.
The modified CQWP web part worked with no problem at all under default itemstyle.xsl
After that, i copied itemstyle.xsl, renamed it to customitemstyle.xsl, and uploaded it to 'XSL Style Sheet' folder under Style Library and published the xsl file.
Once i published the file, i opened modified CQWP (.webpart file) in SPD then made a change to get modified xsl file applied. the change is listed below;
<property name="ItemXslLink" type="string" />/Style Library/XSL Style Sheets/customitemstyle.xsl</property>
After i uploaded the new CQWP, I tried to add the CQWP to a page but got an error saying cannot add webpart and make sure it is correct web part file (.dwp or .webpart file) and make sure the xml is well formed xml.
Now I get stucked to resolve the error and apply custom itemstyle to CQWP.
Can anybody help me? Did I miss anything?
Any comments, guide and direction will be appreciated.
Thank you.
You've probably figured it out by now, but the XML you have provided in your post isn't valid.
The property element is closed twice:
<property name="ItemXslLink" type="string" />XSL path</property>
First with a />-tag and after that the </property>-tag.