Skip to content

Commit

Permalink
Migrated to PrimeFaces 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
djmj committed Oct 14, 2021
1 parent 010ae2b commit b555884
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 94 deletions.
11 changes: 8 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.8
7 changes: 7 additions & 0 deletions .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="primefaces-mobile">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/target/generated-sources/maven-jsf-plugin"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>
5 changes: 5 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.wst.validation.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ It contained some interesting mobile only UI components and renderer of existing
## Download JAR

* [7.0](https://cdn.deloma.de/others/libraries/primefaces/primefaces-mobile-7.0.jar) - compatible to PrimeFaces-7.0
* [8.0](https://cdn.deloma.de/others/libraries/primefaces/primefaces-mobile-8.0.jar) - compatible to PrimeFaces-8.0

## Showcase

Expand All @@ -35,14 +36,20 @@ There are many mobile optimized renders of existing PrimeFaces component such as

## Changes

### 6.1 -> 7.0
### 7.0

- set java compilation level to 1.5
- adapted Java classes to PrimeFaces 7.0 changes
- migrated Renderer classes to new DOM / CSS of jquery 1.5
- replaced jquery mobile with version 1.5.0-rc1
- migrated widgets to new DOM / CSS
- added font-awesome icon support via CSS

### 8.0

- adapted Java classes to PrimeFaces 8.0 changes
- set java compilation level to 1.8

- /java
- adapted Java classes to PrimeFaces 7.0 changes
- migrated Renderer classes to new DOM / CSS of jquery 1.5
- /resources
- replaced jquery mobile with version 1.5.0-rc1
- migrated widgets to new DOM / CSS

**Components**

Expand All @@ -68,7 +75,7 @@ This project basically extracts this commit [Remove mobile](https://github.com/p

### jQuery

PrimeFaces 7.0 uses jQuery 3+ whereas mobile version below 7.0 were only compatible up to 1.9 which leads to breaking changes. [Download mobile](https://releases.jquery.com/mobile/).
PrimeFaces 7.0 or higher uses jQuery 3+ whereas mobile version below 7.0 were only compatible up to 1.9 which leads to breaking changes. [Download mobile](https://releases.jquery.com/mobile/).

### Build from source

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<groupId>org.primefaces</groupId>
<artifactId>primefaces-mobile</artifactId>
<packaging>jar</packaging>
<version>7.0</version>
<version>8.0</version>
<name>primefaces-mobile</name>
<url>http://www.primefaces.org</url>

Expand Down Expand Up @@ -103,7 +103,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>7.0</version>
<version>8.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -123,8 +123,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<source>1.8</source>
<target>1.8</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -196,7 +196,7 @@
<componentConfigsDir>target/resources-maven-jsf/ui</componentConfigsDir>
<standardFacesConfig>src/main/resources-maven-jsf/standard-faces-config.xml</standardFacesConfig>
<standardRenderersConfig>src/main/resources-maven-jsf/standard-renderers.xml</standardRenderersConfig>
<jsfVersion>2</jsfVersion>
<jsfVersion>2.3</jsfVersion>
</configuration>
<goals>
<goal>generate-faces-config</goal>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/primefaces/mobile/event/SwipeEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

public class SwipeEvent extends AbstractAjaxBehaviorEvent {

private static final long serialVersionUID = -244177623519008697L;

private Object data;

public SwipeEvent(UIComponent component, Behavior behavior, Object data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.primefaces.component.accordionpanel.AccordionPanel;
import org.primefaces.component.tabview.Tab;
import org.primefaces.mobile.util.MobileRenderUtils;
import org.primefaces.mobile.util.MobileUtils;
import org.primefaces.util.HTML;
import org.primefaces.util.WidgetBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,42 @@ protected void encodePanel(FacesContext context, AutoComplete ac) throws IOExcep
writer.endElement("div");
}

@Override
protected void encodeSuggestions(FacesContext context, AutoComplete ac, List items) throws IOException {
@SuppressWarnings("rawtypes")
@Override
protected void encodeSuggestions(FacesContext context, AutoComplete ac, Object items) throws IOException {
ResponseWriter writer = context.getResponseWriter();
String var = ac.getVar();
boolean pojo = (var != null);
Map<String,Object> requestMap = context.getExternalContext().getRequestMap();
Converter converter = ComponentUtils.getConverter(context, ac);
boolean hasContent = (ac.getChildCount() > 0);

for(Object item : items) {
writer.startElement("a", null);
writer.writeAttribute("href", "#", null);
writer.writeAttribute("class", MOBILE_ITEM_CLASS, null);

if(pojo) {
requestMap.put(var, item);
String value = (converter == null) ? (String) ac.getItemValue() : converter.getAsString(context, ac, ac.getItemValue());
writer.writeAttribute("data-item-value", value, null);
writer.writeAttribute("data-item-label", ac.getItemLabel(), null);

if(hasContent)
renderChildren(context, ac);
else
writer.writeText(ac.getItemLabel(), null);
}
else {
writer.writeAttribute("data-item-label", item, null);
writer.writeAttribute("data-item-value", item, null);

writer.writeText(item, null);
}

writer.endElement("a");
}
if (items != null && items instanceof List)
for(Object item : (List)items) {
writer.startElement("a", null);
writer.writeAttribute("href", "#", null);
writer.writeAttribute("class", MOBILE_ITEM_CLASS, null);

if(pojo) {
requestMap.put(var, item);
String value = (converter == null) ? (String) ac.getItemValue() : converter.getAsString(context, ac, ac.getItemValue());
writer.writeAttribute("data-item-value", value, null);
writer.writeAttribute("data-item-label", ac.getItemLabel(), null);

if(hasContent)
renderChildren(context, ac);
else
writer.writeText(ac.getItemLabel(), null);
}
else {
writer.writeAttribute("data-item-label", item, null);
writer.writeAttribute("data-item-value", item, null);

writer.writeText(item, null);
}

writer.endElement("a");
}

if(pojo) {
requestMap.remove(var);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.primefaces.component.api.AjaxSource;
import org.primefaces.component.api.UIOutcomeTarget;
import org.primefaces.component.menu.AbstractMenu;
import org.primefaces.mobile.util.MobileConstants;
import org.primefaces.mobile.util.MobileRenderUtils;
import org.primefaces.mobile.util.MobileRenderUtils.IconPos;
import org.primefaces.mobile.util.MobileUtils;
Expand Down Expand Up @@ -99,12 +98,14 @@ protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem
}

String command;
if(menuitem.isDynamic()) {
String menuClientId = menu.getClientId(context);
Map<String,List<String>> params = menuitem.getParams();
if(params == null) {
params = new LinkedHashMap<String, List<String>>();
}
String menuClientId = menu.getClientId(context);

Map<String,List<String>> params = menuitem.getParams();
if(params == null)
params = new LinkedHashMap<String, List<String>>();

if(menuitem.isDynamic())
{
List<String> idParams = new ArrayList<String>();
idParams.add(menuitem.getId());
params.put(menuClientId + "_menuid", idParams);
Expand All @@ -114,7 +115,9 @@ protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem
: buildNonAjaxRequest(context, menu, form, menuClientId, params, true);
}
else {
command = menuitem.isAjax() ? buildAjaxRequest(context, (AjaxSource) menuitem, form) : buildNonAjaxRequest(context, ((UIComponent) menuitem), form, ((UIComponent) menuitem).getClientId(context), true);
command = menuitem.isAjax()
? buildAjaxRequest(context, (UIComponent & AjaxSource) menuitem, form)
: buildNonAjaxRequest(context, ((UIComponent) menuitem), form, menuClientId, true);
}

onclick = (onclick == null) ? command : onclick + ";" + command;
Expand All @@ -134,7 +137,6 @@ protected void encodeMenuItem(FacesContext context, AbstractMenu menu, MenuItem
writer.endElement("a");
}


@Override
protected String getLinkStyleClass(MenuItem menuitem)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void encodeMarkup(FacesContext context, Button button) throws IOException
ResponseWriter writer = context.getResponseWriter();
String clientId = button.getClientId(context);
Object value = button.getValue();
String icon = button.resolveIcon();
String icon = button.getIcon();

writer.startElement("button", button);
writer.writeAttribute("id", clientId, "id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void encodeScript(FacesContext context, UICalendar uicalendar, String
Locale locale = uicalendar.calculateLocale(context);
String pattern = uicalendar.calculatePattern();
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithDomReady("Calendar", calendar.resolveWidgetVar(), clientId);
wb.init("Calendar", calendar.resolveWidgetVar(), clientId);

wb.attr("popup", calendar.isPopup())
.attr("locale", locale.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ private PaginatorRenderer getPaginatorRenderer(FacesContext context) {
PaginatorRenderer renderer = ComponentUtils.getUnwrappedRenderer(
context,
"org.primefaces.component",
"org.primefaces.component.PaginatorRenderer",
PaginatorRenderer.class);
"org.primefaces.component.PaginatorRenderer");

return renderer;
}
Expand Down
50 changes: 27 additions & 23 deletions src/main/java/org/primefaces/mobile/renderkit/DataListRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

import java.io.IOException;
import java.util.Map;

import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.primefaces.component.api.UIData;
import org.primefaces.component.datalist.DataList;
import org.primefaces.component.datalist.DataListState;
import org.primefaces.mobile.renderkit.paginator.PaginatorRenderer;
import org.primefaces.util.ComponentUtils;
import org.primefaces.util.WidgetBuilder;
Expand All @@ -47,8 +50,18 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
}

encodeList(context, list);

if (list.isMultiViewState()) {
DataListState ls = list.getMultiViewState(true);
ls.setFirst(list.getFirst());
ls.setRows(list.getRows());
}
}
else {

if (list.isMultiViewState())
list.restoreMultiViewState();

encodeMarkup(context, list);
encodeScript(context, list);
}
Expand Down Expand Up @@ -130,28 +143,20 @@ protected void encodeList(FacesContext context, DataList list) throws IOExceptio

renderDynamicPassThruAttributes(context, list);

for (int i = first; i < pageSize; i++) {
if(varStatus != null) {
requestMap.put(varStatus, new org.primefaces.component.datalist.DataListRenderer.VarStatus(first, (pageSize - 1), (i == 0), (i == (rowCount - 1)), i, (i % 2 == 0), (i % 2 == 1), 1));
}

list.setRowIndex(i);
list.forEachRow((status) -> {
try
{
writer.startElement("li", null);
renderChildren(context, list);
writer.endElement("li");
}
catch (IOException e)
{
throw new FacesException(e);
}

});

if (list.isRowAvailable()) {
writer.startElement("li", null);
renderChildren(context, list);
writer.endElement("li");
}
}

list.setRowIndex(-1);

if(varStatus != null) {
requestMap.remove(varStatus);
}



writer.endElement(listTag);
}

Expand All @@ -172,8 +177,7 @@ private PaginatorRenderer getPaginatorRenderer(FacesContext context) {
PaginatorRenderer renderer = ComponentUtils.getUnwrappedRenderer(
context,
"org.primefaces.component",
"org.primefaces.component.PaginatorRenderer",
PaginatorRenderer.class);
"org.primefaces.component.PaginatorRenderer");
return renderer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ private PaginatorRenderer getPaginatorRenderer(FacesContext context) {
PaginatorRenderer renderer = ComponentUtils.getUnwrappedRenderer(
context,
"org.primefaces.component",
"org.primefaces.component.PaginatorRenderer",
PaginatorRenderer.class);
"org.primefaces.component.PaginatorRenderer");
return renderer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DialogRenderer extends org.primefaces.component.dialog.DialogRender
protected void encodeScript(FacesContext context, Dialog dialog) throws IOException {
String clientId = dialog.getClientId(context);
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithDomReady("Dialog", dialog.resolveWidgetVar(), clientId);
wb.init("Dialog", dialog.resolveWidgetVar(), clientId);

wb.attr("visible", dialog.isVisible(), false)
.attr("modal", dialog.isModal(), false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void encodeMarkup(FacesContext context, Growl growl) throws IOExceptio

protected void encodeScript(FacesContext context, Growl growl) throws IOException {
WidgetBuilder wb = getWidgetBuilder(context);
wb.initWithDomReady("Growl", growl.resolveWidgetVar(), growl.getClientId(context));
wb.init("Growl", growl.resolveWidgetVar(), growl.getClientId(context));
wb.attr("sticky", growl.isSticky(), false)
.attr("life", growl.getLife(), 6000)
.attr("escape", growl.isEscape(), true)
Expand Down
Loading

0 comments on commit b555884

Please sign in to comment.