Skip to content

Instantly share code, notes, and snippets.

View CedricL46's full-sized avatar

Cedric L CedricL46

View GitHub Profile
@CedricL46
CedricL46 / uploadedFileToFileConverter.java
Created January 11, 2019 11:18
Read full tutorial on how to convert org.apache.myfaces.trinidad.model to java.io.File here :
public static File uploadedFileToFileConverter(UploadedFile uf) {
InputStream inputStream = null;
OutputStream outputStream = null;
//Add you expected file encoding here:
System.setProperty("file.encoding", "UTF-8");
File newFile = new File(uf.getFilename());
try {
inputStream = uf.getInputStream();
outputStream = new FileOutputStream(newFile);
int read = 0;
//Function to call as follow :
//setRichTableSelectedRowAttributeValue("YOUR_TABLE_JSF_ID", "YOUR_VO_ATTRIBUTE_NAME", "THE_NEW_VALUE_TO_SET");
public void setRichTableSelectedRowAttributeValue(String tableID, String attributeName, Object newAttributeValueToSet) {
Object value = null;
RichTable richTable = (RichTable)JSFUtils.findComponentInRoot(tableID);
if (richTable != null) {
RowKeySet rks = richTable.getSelectedRowKeys();
Iterator it = rks.iterator();
while (it.hasNext()) {
##################################################################################################################
### You need to update 4 files to remove the memory limit and strongly improve your jdeveloper performance : ###
##################################################################################################################
##################################################################################################################
### Update the jdev.conf file (e.g : XXXX\Middleware\jdeveloper\jdev\bin\jdev.conf) ############################
##################################################################################################################
##################################################################################################################
### Your JDK need to be at least 1.7 for jdev to use a huge number of memory ###################################
/*** In YOURJSF.jsf button, or other component that need to execute a javascript on action, add : ****/
<af:commandButton text="ClickMe" id="cb1" actionListener="#{YOURSCOPE.YOURJAVABEAN.clickToExecuteJavascriptAction}"/>
/*** In YOURJAVABEAN.java class add : ***/
public void clickToExecuteJavascriptAction(ActionEvent actionEvent) {
this.executeClientJavascript("console.log('You just clicked : " + actionEvent.getSource() + " ')");
//Note: if you use a java string value in this function you should escape it to avoid breaking the javascript.
//Like this : stringValue.replaceAll("[^\\p{L}\\p{Z}]", " ")
}
//Oracle ADF ActionEvent to duplicate a row
public void duplicateRowLine(ActionEvent e) {
ViewObject vo = this.getViewObjectFromIterator("YOUR_ITERATOR_NAME");
Row currentRow = vo.getCurrentRow();
Row duplicatedRow = vo.createRow();
AttributeDef[] voKeyAttributes = vo.getKeyAttributeDefs(); //List of the primary keys that need to be unique
String[] currentRowAttributes = currentRow.getAttributeNames();
for (String attributeName : currentRowAttributes) {
int attributeIndex = duplicatedRow.getAttributeIndexOf(attributeName);
//Check if the attribute is updatable
<!-- In Oracle ADF, To fix JBO-27200: JNDI failure. Unable to lookup Data Source
you need to ensure that your datasource name is the same in 3 places:
Note : This is case sensitive.
-->
<!-- In web.xml -->
<resource-ref>
<res-ref-name>jdbc/YOUR_DATASOURCE_NAME</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<!-- This DataBinding.cpx is usually found at ViewController/adfmsrc/view/DataBinding.cpx -->
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://xmlns.oracle.com/adfm/application" version="11.1.2.61.83" id="DataBindings"
SeparateXMLFiles="false" Package="view" ClientType="Generic">
<definitionFactories>
<factory nameSpace="http://xmlns.oracle.com/adfm/dvt"
className="oracle.adfinternal.view.faces.dvt.model.binding.FacesBindingFactory"/>
</definitionFactories>
<pageMap>
<page path="YOUR_FRAGMENT_PATH/YOUR_FRAGMENT.jsff" usageId="view_YOUR_PAGEPageDef"/>
#SSH to your instance
#example :
#chmod 600 YOURPEMKEY.pem
#ssh -i YOURPEMKEY.pem ec2-user@YOURELASTICIP
#update current packages
sudo yum update -y
#install prerequisites
sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#Connect to the Weblogic Host through FTP and upload your keystore.jks and truststore.jks to your user home
#Connect to the Weblogic Host through SSH with your user
#Copy the trustStore and keyStore to a tmp folder available from your {YourWeblogicUser}
[{YourSSHUser}@{YourWeblogicHost} ~]$ cp truststore.jks /tmp/
[{YourSSHUser}@{YourWeblogicHost} ~]$ cp keystore.jks /tmp/
#Sudo to {YourWeblogicUser}
[{YourSSHUser}@{YourWeblogicHost} ~]$ sudo su - {YourWeblogicUser}
#Copy files to {YourWeblogicDomainPath}/{YourWeblogicDomainName}/certificates
[{YourWeblogicUser}@{YourWeblogicHost} ~]$ mkdir {YourWeblogicDomainPath}/{YourWeblogicDomainName}/certificates
[{YourWeblogicUser}@{YourWeblogicHost} ~]$ cp /tmp/truststore.jks {YourWeblogicDomainPath}/{YourWeblogicDomainName}/certificates
# Open a command terminal in the bin folded of your java installation (e.g: C:\Program File(x86)\Java\jreXXXX\bin)
# In the commands below :
# - selfsigned is the name of the certificate
# - storPass is the password of the keystore and truststore
# - keyPass is the password of the certificate
# You can change those values for yours
#Generate the keystore.jks
keytool -genkeypair -alias selfsigned -keyalg RSA -keysize 2048 -validity 365 -keypass keyPass -storepass storPass -keystore keystore.jks
#Enter your informations when prompt