cancel
Showing results for 
Search instead for 
Did you mean: 

customize action block

Former Member
0 Kudos

Hi All

i have created jar file to create my own action block for converting text to xml

my jar file is in C:\j2sdk1.4.2_11\bin\MyAction.jar

this jar file conatins TextToXml.class and XMLParser.png

I am unable to craete jar file with the following path

C:\j2sdk1.4.2_11\bin jar -cvf TextToXml.jar C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes\com\lighthammer\xacute\actions\TextToXml.class

"C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes\com\lighthammer\xacute\actions\resources\icons\XMLParser.png"

then after this how to create key for the jar file

C:\j2sdk1.4.2_11\bin keytool -genkey

Thanks & Regards

Namita

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Namita,

Yeah, i think thats what Rick is saying. Have your own Catalog file saved in the same folder containing only your Category settings.

You seem to still be referring to com.lighthammer....., this is the namespace we are talking about. You need to change that to something like com.<NOT LIGHTHAMMER>... Know what I mean?

Of course you will then need to change where you store your class, the png path in the java code, your JAR command etc.

The 'lighthammer' string should only appear in your import statements, nowhere else.

Your manifest looks OK, apart from the lighthammer bits.

Regards,

Matt Tuohy

Former Member
0 Kudos

Simply create your own XML file and drop it in the Components directory. You can have your own categories and such as well.

Be warned that failure to do so will almost certainly result in migration or upgrade issues (perhaps even issues with patches), as any files shipped as part of xMII can and will likely be overwritten.

Always try to design extensions by "enhancement" rather than "replacement".

Former Member
0 Kudos

Exactly what Rick said, use your own namespaces.

This is why I have 'companyx' in the whitepaper. You should not add any of your custom work to the lighthammer path.

I didn't realize you could create your own catalog xml file, thanks for the into Rick.

That is a much better solution.

Also Namita, your JAR file should contain a manifest. This is created for you.

When you view the contents of the manifest, you should see an index with corresponding classpaths, correct?

Matt

Former Member
0 Kudos

Hi

can you elaborate more on what you said "create your own catalog xml file "

i added the following code in CoreComponentCatalog

<Category Name="MyObjects" Description="MyObjects">

<Component Type="Action" Name="TextToXml" Description="" Label="TextToXml" ClassName="com.lighthammer.xacute.actions.TextToXml" AssemblyName="TextToXml.jar" HelpFileName=""/>

</Category>

did you mean that i should create Xml like core component catalog and have my custom code there for creating action block

and regarding jar file i have the following content in manifest

Manifest-Version: 1.0

Created-By: 1.4.2_11 (Sun Microsystems Inc.)

Name: com/lighthammer/xacute/actions/TextToXml.class

SHA1-Digest: Rbp+5xyhOhkimWKFdKDshHtdQ74=

Name: com/lighthammer/xacute/actions/resources/icons/XMLParser.png

SHA1-Digest: 64f8/bZV2BBxaFDlTw8UMshCBFs=

Your reply are appreciable

Thanks & Regards

Namita

Former Member
0 Kudos

A few comments:

- You should never, ever build custom action that are in the xMII namespaces. You should always use your own namespace.

- Also, be sure to add a new XML file to the components directory - never, ever edit one of the existing ones.

Version 12.0 will have a more formal packaging and deployment model for custom actions.

- Rick

Former Member
0 Kudos

Have you then placed the XMLParser.png file in the resources\icons folder under actions?

When you open the JAR in winzip, do you see the correct com paths?

Have you got any companyx strings hardcoded in your class?

Matt

Former Member
0 Kudos

Hi Matthew

following is my code which is compiled and converted to TextToXml.class

package com.lighthammer.xacute.actions;

import com.lighthammer.xacute.actions.ActionReflectionBase;

import com.lighthammer.xacute.core.ILog; import com.lighthammer.xacute.core.Transaction;

import com.lighthammer.xml.XMLDataType;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class TextToXml extends ActionReflectionBase {

public TextToXml()

{

_texttoparse = "";

}

public String getTextToParse()

{

return _texttoparse;

}

public void setTextToParse(String s)

{

_texttoparse = s;

}

public XMLDataType getContent()

{

return _xmlcontent;

}

public void setContent(XMLDataType s)

{

_xmlcontent = s;

}

public String GetIconPath()

{

return "/com/lighthammer/xacute/actions/resources/icons/XMLParser.png";

}

public void Invoke(Transaction transaction, ILog ilog)

{

_xmlcontent = new XMLDataType();

try

{

String xmlContent = xmlDecode(_texttoparse);

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = domFactory.newDocumentBuilder();

Document doc = builder.parse(new org.xml.sax.InputSource(new java.io.StringReader(xmlContent)));

_xmlcontent = new XMLDataType(doc);

_success = true;

}

catch(Exception ex)

{

_success = false;

}

}

private String xmlDecode(String strIn)

{

strIn = stringReplace(strIn, "&amp;", "&");

strIn = stringReplace(strIn, "&lt;", "<");

strIn = stringReplace(strIn, "&gt;", ">");

strIn = stringReplace(strIn, "&apos;", "'");

strIn = stringReplace(strIn, "&quot;", "\"");

return strIn;

}

private String stringReplace(String strSource, String strSearch, String strReplace)

{

StringBuffer sb = new StringBuffer();

int nLastPos = 0;

for(int nPos = strSource.indexOf(strSearch, nLastPos); nPos >= 0; nPos = strSource.indexOf(strSearch, nLastPos))

{

sb.append(strSource.substring(nLastPos, nPos));

sb.append(strReplace);

nLastPos = nPos + strSearch.length();

}

sb.append(strSource.substring(nLastPos, strSource.length()));

return sb.toString();

}

private String _texttoparse;

private XMLDataType _xmlcontent;

}

in jar file i get the following path

for class file com\lighthammer\xacute\actions

for png file com\lighthammer\xacute\actions\resources\icons

Regards

Namita

Former Member
0 Kudos

Namita,

I have responded in the original thread.

Regards,

Matt Tuohy

Former Member
0 Kudos

Hi Matthew

yeah i have changed that . TextToXml.class was created in C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes

from here i cut it and pasted .class in C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes\com\lighthammer\xacute\actions

I copied my jar file created in created in C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes to C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\CMSLogicEditor

made all the necessary changes in xml catalog , restarted the xMII server .

when i open my Buisness Logic Editor there i find only tab "my objects"on left side which has no nested action block

Your response will be appreciable

Regards

Namita

Message was edited by:

Namita Tripathi

Former Member
0 Kudos

Namita,

Did you sign the JAR file?

Is the class and PNG in the JAR file with the path corresponding to the file systems?

You may need to send me more info...

Regards,

Matt Tuohy

Former Member
0 Kudos

Hi

i will tell you step by step process what i did

1) C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes>path c:\j2sdk1.4.2_11\bin

2)C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes>javac TextToXml.java

3)here TextToXml.class was created

4)then to create jar file

C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes>jar -cvf TextToXml.jar com\lighthammer\xacute\actions\TextToXml.class "com\lighthammer\xacute\actions\resources\icons\XMLParser.png"

5)This created my jar file TextToXml.jar with .class and png file

6)i assigned it a key by

C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes>jarsigner TextToXml.jar colinmaxwell

7)jar folder with .class , png file and keystore is created

i pasted this class file in C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\WEB-INF\classes\com\lighthammer\xacute\actions

😎 jar file in C:\ServletExec AS\se-xMII\webapps\default\Lighthammer\CMSLogicEditor

let me know what else you require

Regards

Namita

0 Kudos

Namita,

Is there any reason why you are not using the "String List to XML" action block included standard in the product? This action will take a comma separated string of values and convert it to XML. For example this string "A,B" will look like:

<Rowsets>

<Rowset>

<Row>

<Item>A</Item>

</Row>

<Row>

<Item>B</Item>

</Row>

</Rowset>

</Rowsets>

Hope this helps.

Regards,

Salvatore Castro