Skip to content

Instantly share code, notes, and snippets.

Cedric L CedricL46

View GitHub Profile
View MigrateSvnProjectToCompanyGitlabGit.sh
#Once your local git can communicate with the gitlab server you can start migrating:
#Inspired from https://john.albin.net/git/convert-subversion-to-git
#First got to your gitlab and add a new project (in this tuto : YOUR_GITLAB_REPO.git)
#check out your svn project, right click in it and run git bash here to run the following command :
#Download all author commit data to update it to Git standard:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
#update the authors-transform.txt file with the git format e.g:
View ConfigureLocalGitToConnectWithCompanyGitLab.sh
#Up to date doc can be found on https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair
#First configure your local git configuration so it can communicate with your gitlab server :
# If you're on windows install git bash for windows if not install git
# This time i'm on windows so :
#Open a git bash command terminal (right click into any folder + git bash here)
#Generate a new ED25519 SSH key pair
#(as a best practice we should always prefer ED25519 to old rsa format)
View retreiveValueOfAnAdfBindingProgrammatically.java
//Here is how to simply retreive the value of and ADF Binding from the view El Expression :
//Below is a view example with values taken from an ADF View Object
<af:inputText id="it1" autoSubmit="true" value="#{bindings.YOUR_VO.YOUR_VO_ATTRIBUTE.inputValue}" />
<af:table value="#{bindings.YOUR_VO.collectionModel}" var="row">
<af:column sortProperty="#{bindings.YOUR_VO.hints.YOUR_VO_ATTRIBUTE.name}"
id="c1">
<af:outputText value="#{row.YOUR_VO_ATTRIBUTE}" id="ot1"/>
</af:column>
</af:table>
@CedricL46
CedricL46 / hideAdfRichTableIfNoDataToDisplay.jsf.xml
Last active Mar 13, 2019
EL Expression to check and hide if an ADF rich table is empty with no data to display
View hideAdfRichTableIfNoDataToDisplay.jsf.xml
<!--
Add visble or rendered attribute :
rendered="#{bindings.YOUR_TABLE_ITERATOR.estimatedRowCount gt 0}"
to your table OR to it's parent layout element
-->
<af:table value="#{bindings.YOUR_TABLE_ITERATOR.collectionModel}" var="row" rows="#{bindings.YOUR_TABLE_ITERATOR.rangeSize}" fetchSize="#{bindings.YOUR_TABLE_ITERATOR.rangeSize}"
varStatus="vs" styleClass="AFStretchWidth"
selectedRowKeys="#{bindings.YOUR_TABLE_ITERATOR.collectionModel.selectedRow}" selectionListener="#{bindings.YOUR_TABLE_ITERATOR.collectionModel.makeCurrent}"
immediate="true" emptyText="#{bindings.YOUR_TABLE_ITERATOR.viewable ? 'No data to display.' : 'Access Denied.'}" id="tableID"
View showAPlaceholderOrATooltipInAnAdfColumnFilterHeader.jsf.xml
<!-- Below an example table on with a column header filter customized to display a place holder and tooltip -->
<af:table value="#{bindings.YourVO.collectionModel}" var="row" rows="#{bindings.YourVO.rangeSize}"
fetchSize="#{bindings.YourVO.rangeSize}" filterModel="#{bindings.YourVOCriteriaQuery.queryDescriptor}"
queryListener="#{bindings.YourVOCriteriaQuery.processQuery}" varStatus="vs"
selectionListener="#{bindings.YourVO.collectionModel.makeCurrent}" rowSelection="single" id="T1"
styleClass="AFStretchWidth"
rowBandingInterval="0" columnBandingInterval="0">
<af:column sortProperty="#{bindings.YourVO.hints.YourVoAttribute.name}" filterable="true" sortable="true" id="Tc1"
width="60">
<!-- Add the following filter facet to modify the header column filter inputText component -->
@CedricL46
CedricL46 / uploadedFileToFileConverter.java
Created Jan 11, 2019
Read full tutorial on how to convert org.apache.myfaces.trinidad.model to java.io.File here :
View uploadedFileToFileConverter.java
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;
View setRichTableSelectedRowAttributeValue.java
//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()) {
View HowToIncreaseJdeveloperPerformance.sh
##################################################################################################################
### 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 ###################################
View executeClientJavascriptInADFJavaBeanOnAction.java
/*** 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}]", " ")
}
View OracleADFDuplicateRowLine.java
//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
You can’t perform that action at this time.