JSF Code formatter or Eclipse XML Editor, each tag for new line?
Asked Answered
L

2

8

How to format JSF code in eclipse?

I already try as the following :

My XML Editor Configuration Setting is :

  • Line width 120
  • Split multiple attributes each on a new like Checked
  • Align final bracket in mulit-line element tags Checked
  • Clear all blank lines Checked

If I do Ctrl + Shif + F, eclipse format the code as below.

<tr>
    <td><h:outputText value="#{label['MANAGE_USER_TITLE']}"
            styleClass="table-title" /></td>

</tr>

My expectation format is, after Ctrl + Shif + F

<tr>        
    <td>
        <h:outputText value="#{label['MANAGE_USER_TITLE']}" styleClass="table-title" /> 
                ▲
                This line may be wrap base on line size.
    </td>
</tr>

How can I do for that? Is there any plugin? I already try HTML Tidy, I can only format HTML, not JSF code.

Update

Picture -1

enter image description here

Eclipse Setting for Picture-1

enter image description here

Picture - 2 (I want)

enter image description here

Lowpressure answered 3/3, 2014 at 5:25 Comment(2)
remove <tr> and <td> tags from the Inline Elements list.Vickievicksburg
@Vickievicksburg thanks, it is my expectation. Could you post as answer with picture or more explanation to make good reference?Lowpressure
V
9

Looking at the Settings panel that Maheshbabu Jammula posted, you can see an Inline Elements list. Just remove <tr> and <td> tags from the list and those tags will always land in a new line. Take Care!

Preferences > Web > HTML Files > Editor

enter image description here

Vickievicksburg answered 3/3, 2014 at 10:41 Comment(2)
Yes @Vickievicksburg Open Window>Preferences>Web>HMTL Files>Editor and you will find list of HTML keywords in textbox called “Inline Elements:”. Remove input and label from this list and all of these statements will be each on separate lines. You can modify more formatter settings there. Line wrapping width is reasonable to be increased with nowadays widescreen monitors.Roca
@Maheshbabu Jammula - not everyone uses Windows, on a Mac there's no Window>PreferencesVickievicksburg
R
6
Ctrl + Shif + F, only formats code.For indent use ctrl+a and ctrl+i

enter image description here

Roca answered 3/3, 2014 at 9:24 Comment(6)
Did u test it my code? It is the same format I don't want.Lowpressure
@cycDemo stay same: Split multiple attributes each on a new like CheckedRoca
Please check my update post. I did not get my expectation(Picture-2) format.Lowpressure
Split multiple attributes each on a new like CheckedRoca
I am sorry, may be my false. Even it is checked or not, it is the same. I already test most the editor and formatter option.Lowpressure
Thank for your supporting! I get useful reference your answer.Lowpressure

© 2022 - 2024 — McMap. All rights reserved.