Skip to content

Commit

Permalink
Various bugfixes:
Browse files Browse the repository at this point in the history
- #217 b:switch didn't send its values to the server 
- #216 added rtl support for languages that write right-to-left
- #215 moved the col-md-xx div of the checkbox to where it belongs
  • Loading branch information
stephanrauh committed Dec 28, 2015
1 parent f051807 commit 0b3dca8
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 64 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/bootsfaces/component/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public void encodeHTML(FacesContext context, Map<String, Object> attrs) throws I
rw.writeAttribute("id", getClientId(context), "id");
rw.writeAttribute("name", getClientId(context), "name");
rw.writeAttribute("type", "button", null);
if (null != attrs.get("dir")) {
rw.writeAttribute("dir", attrs.get("dir"), "dir");
}
if (style != null) {
rw.writeAttribute(STYLE, style, STYLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
rw.writeAttribute("type", type, null);
rw.writeAttribute("id", CID, "id");
rw.writeAttribute("name", CID, "name");
if (null != commandButton.getDir()) {
rw.writeAttribute("dir", commandButton.getDir(), "dir");
}


Tooltip.generateTooltip(context, commandButton, rw);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
}

rw.startElement("div", component);
if (null != inputText.getDir()) {
rw.writeAttribute("dir", inputText.getDir(), "dir");
}

Tooltip.generateTooltip(context, inputText, rw);
rw.writeAttribute("id", clientId, "id");
rw.writeAttribute("class", "form-group", "class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
}

rw.startElement("div", component);
if (null != inputText.getDir()) {
rw.writeAttribute("dir", inputText.getDir(), "dir");
}

Tooltip.generateTooltip(context, inputText, rw);
rw.writeAttribute("id", clientId, "id");
rw.writeAttribute("class", "form-group", "class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
if (null != messageList && (!messageList.isEmpty())) {
rw.startElement("div", message);
writeAttribute(rw, "id", clientId);
if (null != message.getDir()) {
rw.writeAttribute("dir", message.getDir(), "dir");
}

String styleClass = message.getStyleClass();
if (null != styleClass && styleClass.length() > 0)
styleClass = styleClass + " ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void encodeEnd(FacesContext facesContext, UIComponent component) throws I
return;
}

UIMessages uiMessages = (UIMessages) component;
Messages uiMessages = (Messages) component;
ResponseWriter writer = facesContext.getResponseWriter();

String clientId = uiMessages.getClientId(facesContext);
Expand All @@ -73,6 +73,10 @@ public void encodeEnd(FacesContext facesContext, UIComponent component) throws I
}

writer.startElement("div", uiMessages);
if (null != uiMessages.getDir()) {
writer.writeAttribute("dir", uiMessages.getDir(), "dir");
}

writer.writeAttribute("id", clientId, "id");

for (String severity : messages.keySet()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
ResponseWriter rw = context.getResponseWriter();
String clientId = selectBooleanCheckbox.getClientId();

int span = startColSpanDiv(rw, selectBooleanCheckbox);
addLabel(rw, clientId, selectBooleanCheckbox);

// "Prepend" facet
Expand All @@ -114,7 +115,6 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
final boolean hasAddon = startInputGroupForAddOn(rw, (prependingAddOnFacet != null),
(appendingAddOnFacet != null), selectBooleanCheckbox);

int span = startColSpanDiv(rw, selectBooleanCheckbox);

addPrependingAddOnToInputGroup(context, rw, prependingAddOnFacet, (prependingAddOnFacet != null),
selectBooleanCheckbox);
Expand Down Expand Up @@ -181,6 +181,10 @@ protected void addLabel(ResponseWriter rw, String clientId, SelectBooleanCheckbo
String label = selectBooleanCheckbox.getLabel();
if (label != null) {
rw.startElement("label", selectBooleanCheckbox);
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}

rw.writeAttribute("for", "input_" + clientId, "for");
rw.writeText(label, null);
rw.endElement("label");
Expand Down Expand Up @@ -315,6 +319,9 @@ protected void renderInputTag(ResponseWriter rw, FacesContext context, SelectBoo
String clientId) throws IOException {
rw.startElement("div", selectBooleanCheckbox);
rw.writeAttribute("id", clientId, null);
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}

Tooltip.generateTooltip(context, selectBooleanCheckbox, rw);

Expand Down Expand Up @@ -428,6 +435,9 @@ protected int startColSpanDiv(ResponseWriter rw, SelectBooleanCheckbox selectBoo
if (span > 0) {
rw.startElement("div", selectBooleanCheckbox);
rw.writeAttribute("class", "col-md-" + span, "class");
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}
}
return span;
}
Expand All @@ -453,6 +463,9 @@ protected boolean startInputGroupForAddOn(ResponseWriter rw, boolean hasPrependi
if (hasAddon) {
rw.startElement("div", selectBooleanCheckbox);
rw.writeAttribute("class", "input-group", "class");
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}
}
return hasAddon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
String clientId = menu.getClientId(context).replace(":", "-");
;
rw.startElement("div", menu);
writeAttribute(rw, "dir", menu.getDir(), "dir");

Tooltip.generateTooltip(context, menu, rw);
rw.writeAttribute("class", "form-group", "class");

Expand Down Expand Up @@ -165,7 +167,14 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
options += "," + "nonSelectedText:'" + nonSelectedText + "'";
}
String nSelectedText = menu.getNSelectedText();
nSelectedText = (String) menu.getAttributes().get("nSelectedText"); // workaround - the regular getter always yields null
nSelectedText = (String) menu.getAttributes().get("nSelectedText"); // workaround
// -
// the
// regular
// getter
// always
// yields
// null
if (nSelectedText != null) {
options += "," + "nSelectedText:'" + nSelectedText + "'";
}
Expand Down Expand Up @@ -195,7 +204,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
if (filterPlaceholder != null) {
options += "," + "filterPlaceholder:'" + filterPlaceholder + "'";
}

boolean enableCaseInsensitiveFiltering = menu.isEnableCaseInsensitiveFiltering();
if (enableCaseInsensitiveFiltering) {
options += "," + "enableCaseInsensitiveFiltering:" + "true";
Expand All @@ -210,7 +219,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
if (dropRight) {
options += "," + "dropRight:" + "true";
}

String onChange = menu.getOnchange();
if (onChange != null) {
options += "," + "onChange:" + onChange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
String clientId = menu.getClientId(context);
rw.startElement("div", menu);
rw.writeAttribute("class", "form-group", "class");
writeAttribute(rw, "dir", menu.getDir(), "dir");

addLabel(rw, clientId, menu);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,53 +28,21 @@

import net.bootsfaces.component.ajax.AJAXRenderer;
import net.bootsfaces.component.selectBooleanCheckbox.SelectBooleanCheckboxRenderer;
import net.bootsfaces.render.Tooltip;


/** This class generates the HTML code of &lt;b:switchWidget /&gt;. */
@FacesRenderer(componentFamily = "net.bootsfaces.component", rendererType = "net.bootsfaces.component.switch.Switch")
public class SwitchRenderer extends SelectBooleanCheckboxRenderer {
/**
* This methods receives and processes input made by the user. More specifically, it ckecks whether the
* user has interacted with the current b:switchWidget. The default implementation simply stores
* the input value in the list of submitted values. If the validation checks are passed,
* the values in the <code>submittedValues</code> list are store in the backend bean.
* @param context the FacesContext.
* @param component the current b:switchWidget.
*/
@Override
public void decode(FacesContext context, UIComponent component) {
Switch switchWidget = (Switch) component;

if (switchWidget.isDisabled() || switchWidget.isReadonly()) {
return;
}

decodeBehaviors(context, switchWidget);

String clientId = switchWidget.getClientId(context);
String submittedValue = (String) context.getExternalContext().getRequestParameterMap().get(clientId);

if (submittedValue != null) {
switchWidget.setSubmittedValue(submittedValue);
}
}

@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
ResponseWriter rw = context.getResponseWriter();
String clientId = component.getClientId();
Switch _switch = (Switch) component;
rw.startElement("input", _switch);
rw.writeAttribute("id", clientId, "id");
renderInputTagAttributes(rw, clientId, _switch);
// Render Ajax Capabilities
AJAXRenderer.generateBootsFacesAJAXAndJavaScript(FacesContext.getCurrentInstance(), _switch, rw);

renderInputTagValue(context, rw, _switch);
rw.endElement("input");
super.encodeBegin(context, component);
clientId=clientId.replace(":","\\\\:");
rw.append("<script>");
rw.append("$('#" + clientId + "').bootstrapSwitch();");
rw.append("$('#input_" + clientId + "').bootstrapSwitch();");
rw.append("</script>");
}
}
22 changes: 8 additions & 14 deletions src/main/meta/META-INF/bootsfaces-b.taglib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -1834,7 +1834,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -3546,7 +3546,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -3862,7 +3862,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -4051,7 +4051,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -4390,7 +4390,7 @@
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -4649,12 +4649,6 @@
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Disables the input element, default is false.]]></description>
<name>disabled</name>
Expand Down Expand Up @@ -5356,7 +5350,7 @@
<type>javax.faces.component.UIComponent</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down Expand Up @@ -5641,7 +5635,7 @@
<type>javax.faces.component.UIComponent</type>
</attribute>
<attribute>
<description><![CDATA[Direction indication for text that does not inherit directionality.]]></description>
<description><![CDATA[Direction indication for text that does not inherit directionality. Legal values: ltr (Default. Left-to-right text direction), rtl (Right-to-left text direction) and auto (let the browser figure out the direction of your alphebet, based on the page content).]]></description>
<name>dir</name>
<required>false</required>
<type>java.lang.String</type>
Expand Down
Loading

0 comments on commit 0b3dca8

Please sign in to comment.