Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Format JSF/XHTML/HTML/... files with each attribute on same line, but column-wise
icon3.gif  Format JSF/XHTML/HTML/... files with each attribute on same line, but column-wise [message #1690203] Wed, 25 March 2015 16:32 Go to next message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 115
Registered: July 2009
Senior Member
In Eclipse, I find no way to format code the way I need to for JSF, XHTML, HTML or XML files like can be configured for Java.

I have found the following part-solutions:

http://stackoverflow.com/questions/22139262/jsf-code-formatter-or-eclipse-xml-editor-each-tag-for-new-line

However, just placing attributes on the next line, indenting them by one is not enough:

    <p:spinner
        id="multi-trade-adjust-count"
        value="#{bulkTradeManager.count}"
        title="Number of trades to create"
        maxlength="2"
        size="1"
        min="1"
        max="50"
        styleClass="bx-spinner mb-5px"
        style="width: 60px;">
        <p:ajax
            listener="#{bulkTradeManager.onCountChange}"
            process="@this"
            update=":content-form:data-panel" />
    </p:spinner>


I am so unhappy with it, that I end up using no JSF formatters at all. What I'm desparately looking for is a result like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:of="http://omnifaces.org/functions"
                    xmlns:p="http://primefaces.org/ui"
                    xmlns:pe="http://primefaces.org/ui/extensions">
    
        <p:dataTable id="multi-data-add"
                     value="#{bulkTradeManager.dataModel}"
                     var="trd"
                     rowIndexVar="rowIndex"
                     rowKey="#{trd.id}"
                     editable="true"
                     editMode="cell"
                     rowStyleClass="#{bulkTradeManager.lastNonRemovableIndex le rowIndex ? 'ui-state-highlight' : ''}"
                     styleClass="mb-10px mr-10px">

            <p:ajax event="cellEdit"
                    listener="#{bulkTradeManager.onCellEdit}"
                    update=":content-form:msgs" />

            <p:ajax event="sort" />
            
            <p:column headerText="#{msg['common.active.header']}"
                      rendered="#{bulkTradeManager.showingConstantColumns}"
                      styleClass="text-center">
                <h:outputText value="#{trd.active ? msg['common.yes.label'] : msg['common.no.label']}" />
            </p:column>
            
            <p:column headerText="#{msg['entity.trade.transactionNbr.shortHeader']}"
                      rendered="#{bulkTradeManager.showingConstantColumns}">
                <h:outputText value="#{trd.transactionNbr}" />
            </p:column>
            
            <p:column headerText="#{msg['entity.trade.referenceNbr.shortHeader']}"
                      sortBy="#{trd.referenceNbr}">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{trd.referenceNbr}" />
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText id="reference-number-input"
                                     value="#{trd.referenceNbr}"
                                     styleClass="width-190px" />
                    </f:facet>
                </p:cellEditor>
            </p:column>
            
            <p:column headerText="#{msg['entity.trade.quantity.header']}/#{msg['common.nominal.header']}*"
                      sortBy="#{trd.quantity}">
                <p:cellEditor>
                    <f:facet name="output">
                        <h:outputText value="#{trd.quantity}">
                            <f:convertNumber maxIntegerDigits="126" pattern="#,###,##0.########" />
                        </h:outputText>
                    </f:facet>
                    <f:facet name="input">
                        <p:inputText id="quantity-input"
                                     value="#{trd.quantity}"
                                     required="false"
                                     requiredMessage="#{msg['entity.trade.quantity.requiredMessage']}"
                                     maxlength="50"
                                     styleClass="width-190px">
                            <pe:keyFilter regEx="/[0-9,.]/i" />
                            <f:convertNumber maxIntegerDigits="126" pattern="#,###,##0.########" />
                        </p:inputText>
                    </f:facet>
                </p:cellEditor>
            </p:column>

            ...

This means, on top of the option "Split multiple attributes each on a new line", at least two sub options need to be present to produce this:

    [✓] Split multiple attributes each on a new line
        [✓] Leave first attribute on the same line as the opening tag
        [✓] Align attributes column-wise

Q: Does anything like this exist?

Maybe a JSF formatter plugin? Maybe there are some hacks via the config files?

As it stands now, JSF, XHTML, XML, HTML etc. formatting is a somewhat incomplete feature, at least the long-term solution would be to offer a configuration that is more like the Java code formatters where almost anything can be configured.

I'd even be tempted to contribute to the Eclipse community, if it's not overly hard to implement the two check boxes described. At least, leaving the first attribute on the same line and using the second character's column index after the opening tag and taking it for all subsequent attributes as indent seems doable to me...

Comments appreciated.

Karsten

[Updated on: Wed, 25 March 2015 23:02]

Report message to a moderator

Re: Format JSF/XHTML/HTML/... files with each attribute on same line, but column-wise [message #1690292 is a reply to message #1690203] Thu, 26 March 2015 11:23 Go to previous message
Karsten Wutzke is currently offline Karsten WutzkeFriend
Messages: 115
Registered: July 2009
Senior Member
Is the formatting triggered by pressing CTRL-SHIFT-F performed by Eclipse WTP or is it the JBoss Tools plugin?? I'm confused.

I thought this is WTP functionality.

Please help.
Previous Topic:Some tags and properties are marked 'unknown' and 'undefined'
Next Topic:weblogic.xml different in hot publish than war
Goto Forum:
  


Current Time: Mon Sep 24 04:20:05 GMT 2018

Powered by FUDForum. Page generated in 0.01863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top