Back in SF for Oracle Open World

I arrived yesterday evening, after staying three weeks in RWS. The city turned red, not only b/c of 150 years of Macy.. :-) In fact a lot of ads are visible for the OpenWorld. Between Moscone N and S, they conference closed the Howard street :-) A tend is now between them. I am here to give a talk on JSF / ADF Faces / Web 2.0. Which is on Sunday afternoon. On Monday and Thursday I am helping out at the OpenSource/Eclipse booth, to handle questions on Apache Trinidad (supported in JDeveloper 11 ;-) )

Thursday night I am flying back home, to old Europe… :-)

Conversion and uploaded files in Trinidad

Trinidad doesn’t (currently) support conversion for uploaded files. Something like this is currently totally ignored:

<tr:inputFile value="#{bean.fileModel}" ...>
  <f:converter converterId="myCustomFileTransformationConverter" />
</tr:inputFile>

That means your backing bean has to have a reference to the UploadedFile model interface. This is OK… but not always desired. Sometimes, when using a special model library, you may want to have the backing bean to have a reference to your model, instead of to the Trinidad interface.

With the upcoming Trinidad 1.2.10 (and 1.1.10) release this will be supported. However, there is a convention you have to follow… The getAsObject() from the Converter interface only accepts String for the value. I guess this was done b/c the standard components only treat Strings and no other (raw) objects like an uploaded file or similar. The main problem is that Java EE has no common API for uploads, but that is a different story…

Back to the convention. The Trinidad library invokes the getAsObject with a KEY, which the converter has to use to lookup the actual uploaded file instance in the request map. This is a work around to the know limitation, but works just great. The key is some “org.apache….” namespace + the filename, but that is really an implementation detail…

A custom getAsObject(…) could look like this:


  public Object getAsObject(FacesContext context, UIComponent component, String fileKey)
  {
    UploadedFile file = (UploadedFile)context.getExternalContext().getRequestMap().get(fileKey);
    // do transformation
    return fileThatIsMyModelFileClass;
  }

So, stay tuned for the upcoming release ;-)