Item input transformers

The following example is given in the Rhythmyx 6.5.2 Implementation Guide for Item input transformers:

if City and State fields are filled in, an item input transform could use them as keys for reading an external file and then filling in a Zip Code field.

I want to me able to do something similar if a one particular field has been populated then I wish to run a lookup to get values for other fields.

I’m not sure exactly where to begin with this and would be greatful for some pointers on how to actually implement this.

You need to create a Java class that implements the IPSItemInputTransformer. The method that the server calls is preProcessRequest.
You use the supplied IPSRequestContext to get the params (fields) of interest, do your processing, then set the generated data back into the request on the target params.
Finally, you then register this class as an extension using the workbench and choose the new exit for the desired content type.

where should i put the java class after i compiled ?!

For this case, I would upload the class file with the extension definition.
If you need to fix bugs, you can edit the extension and reload the class file by editing/saving the extension. You need to restart the editor that you are using this extension with in order to pick up the new class (running editors/apps will continue to use the previously loaded extension until the app restarts.)

I’m not sure how does it work, like do i need to compile the .java file into .class file, if i do, where the .class should place to. Or actually can i upload the .java file through the workbench?! Is there any documentation about that?!

Daniel,

These extensions are Java classes. You can find any number of resources that describe how to program in Java.

The requirements specific to Rhythmyx are documented in the Rhythmyx Technical Reference.

RLJII

I have managed now to create a very simple extension, register it in rhythmyx and use it in a Content Type.

What I would like to do is use the output of a rhythmyx application in this extension.

The specific scenario is that we have a country and a continent drop down on a content type. The drop downs are populated by the output of two applications which pull the values from a table we have created in the database.

When the user submits the item we want to confirm that the country and continent selected are consistent (i.e. the country is in the continent) and if not correct the selected continent.

Would it be possible to use an application which would take the selected country and return the correct continent and either pass its result into the extension or call it from the extension?

Or - is there another way to do this which I am missing?

Just wanted to check if there is a simpler way of achieving our goal.

All the data lists exist within the Rhythmyx database repository.

We want to populate the value of a field in one drop down list based on what has been input from another. We already have XML applications that can retrieve the correct values based on what is passed.

Our problem is what, if any, existing processor to use? We have come to a bit of a dead end in writing our own due to the fact we cannot figure out how to access our XML applications from our Java Extensions.

Well, if all you are looking for is dropdown lists that are populated from a Rhythmyx application, you certainly don’t need to write an Input Transform.

First, make sure that your XML application resource returns an XML document in the format specified by sys_lookup.dtd.

Then, in the “Control Properties” of the dropdown control, select the “Choices” tab and select the “Retrieve from xml application” radio button. Pressing the ellipsis button ("…") will bring up a dialog where you can select the XML Application, the resource name and add any parameters.

I hope this helps.

Dave

In the transformer, use IPSRequestContext.getInternalRequest(…). You supply the name of your app as a parameter. Call getResultDoc() on the return value and retrieve your desired value.
If you can always calculate the continent, would it be better to make it a read-only field to save the user from filling it in (potentially incorrectly.)

Thanks,

That was what we were looking for and we now have this working.

The user is also aload to just pick a continent which means we can’t remove it from the form.

Another aspect we would like to add now is to prevent the row being entered into the child table with a useful message when the fields have certain values in (for example if they are all empty).

Is it possible to do this?

[QUOTE=fosterd;3431]Another aspect we would like to add now is to prevent the row being entered into the child table with a useful message when the fields have certain values in (for example if they are all empty).

Is it possible to do this?[/QUOTE]

The question was recently addressed on this forum: http://forum.percussion.com/showthread.php?t=762

RLJII

Hi - thanks for the response.

I had already tried a stab in the dark throwing a PSConversion exception - hoping Ryhthmyx caught them and displayed the message - but it just prevented the page displaying.

Should this have worked?

Can anyone point me to any documentation on this?

Cheers.

To validate field values, you should add a validation check on each field of interest. This is done in the workbench. Choose the field of interest in the content type editor, then click on the ‘Validation’ button at the bottom of the editor.

Can anyone post a sample java source file?

I did not realize sample java code (below) is included under the cms root.

Once I have my java class where is the configuration file located to import my jar file? Would I just append it to this string:
/cms/Rhythmyx/JRE/bin/java -cp :JRE/lib/tools.jar:AppServer/bin/run.jar: -Dprogram.name=RhythmyxServer.exe -Xms128m

/******************************************************************************
*

  • [ PSValidateStringPattern.java ]
  • COPYRIGHT © 1999 - 2006 by Percussion Software, Inc., Woburn, MA USA.
  • All rights reserved. This material contains unpublished, copyrighted
  • work including confidential and proprietary information of Percussion.

*****************************************************************************/
package com.percussion.validate;

import com.percussion.data.PSConversionException;
import com.percussion.extension.IPSExtensionDef;
import com.percussion.extension.IPSFieldValidator;
import com.percussion.extension.PSExtensionException;
import com.percussion.extension.PSExtensionParams;
import com.percussion.server.IPSRequestContext;

import java.io.File;
import java.util.regex.Pattern;

public class PSValidateStringPattern implements IPSFieldValidator
{

public Object processUdf(Object[] params, IPSRequestContext request) throws PSConversionException
{
String value, regex;
PSExtensionParams ep = new PSExtensionParams(params);
value = ep.getStringParam(0, null, false);
regex = ep.getStringParam(1, null, true);

  if (value == null)
  {
     return false;
  }
  
  if (value == null || !Pattern.matches(regex,value))
  {
     return false;
  }

  return true;

}

public void init(IPSExtensionDef def, File codeRoot) throws PSExtensionException
{
//
}

}

You need to register your extension using the Workbench. Under the “System” tab or view, there is a list of the currently registered extensions. You can add a new extension registration there. You can either upload the jar file as part of the extension registration, or you can add it to the rxapp.war/web-inf/lib directory on the server and restart Rhythmyx.

Do you happen to know which jar file contains these classes?

com.percussion.data.PSConversionException;
com.percussion.extension.IPSExtensionDef;
com.percussion.extension.IPSFieldValidator;
com.percussion.extension.PSExtensionException;
com.percussion.extension.PSExtensionParams;
com.percussion.server.IPSRequestContext

*Found it using grep “IPSRequestContext” *.jar: /cms/Rhythmyx/AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib/rxclient.jar

** I spoke to soon, these do not seem to be the right version of the classes. Perhaps there is another jar in a different directory?

Here is the error I get:

Error(3,28): cannot access class com.percussion.data.PSConversionException; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0

Error(13,59): class IPSFieldValidator not found in class erau.ValidateStringPatternDoesNotExist

My jdeveloper classpath includes:

C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\providerutil.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\psinstaller.exe;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\psjniregistry.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rhythmyx.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxagent.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxclient.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxcontentui.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxextensions.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxff.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxi18n.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxinstall.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxmisctools.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxpublisher.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxserver.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxservices.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxservlet.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxsimple.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxtablefactory.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxutils.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxwebservices.jar;C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib\rxworkflow.jar