哪个 JSF 组件在非编辑模式下显示文本区域?
Which JSF component to display a text area in non editing mode?
我想显示在两种模式下使用的文本区域:
- 一种修改方式,使用p:editor
- 一种可视化模式,其中只有文本区域可见。
哪个组件是这种可视化模式的最佳选择?我试过 :
- p : editor : 我不想让工具栏可见。看来是隐藏不了了
- p:outputTextarea : html 由 p:editor 生成的标签在文本区域可见
- h: outputText : 渲染与 p:editor 略有不同,最重要的是,由于没有垂直滚动条,文本会溢出其容器。
我也尝试过使用 p:outputTextarea 进行编辑和可视化模式,但我会对 p:editor 中提供的更多工具感兴趣。
有什么想法吗?
<p:panel id="panelDG">
<p:dataGrid id="pdatagrid1" layout="grid" value="#{ib.bloc.groups}" var="group" columns="#{ib.bloc.groupsSize}" rowIndexVar="status">
<!-- other components -->
<p:panel styleClass="panel-textarea">
<s:account>
<p:editor id="editor1" value="#{ib.textArea1}" rendered="#{status == 0}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<p:editor id="editor2" value="#{ib.textArea2}" rendered="#{status == 1}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<p:editor id="editor3" value="#{ib.textArea3}" rendered="#{status == 2}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<h:panelGrid >
<p:commandButton value="Save" action="#{ib.modifyGroupText(group)}" icon="ui-icon-disk" />
</h:panelGrid>
</s:account>
<s:guest>
<h:outputText value="#{group.textArea}" escape="false"></h:outputText>
</s:guest>
</p:panel>
</p:dataGrid>
</p:panel
.panel-textarea{
height: 500px;
}
如果你想隐藏 <p:editor>
的工具栏,因为用户没有编辑权限,你可以简单地使用 css.
Facelet
<p:editor styleClass="#{!login.editAccess ? 'hideToolbar' : ''}" disabled="#{!login.editAccess}" ... />
CSS
.hideToolbar .ui-editor-toolbar {
display: none;
}
哦,我还没有看到 .ui-editor-toolbar class !
否则,使用h:outputText时避免文本溢出:
.h-outputText{
display:block !important;
overflow-y: auto !important;
height: 400px !important;
}
感谢大家的回答
我想显示在两种模式下使用的文本区域:
- 一种修改方式,使用p:editor
- 一种可视化模式,其中只有文本区域可见。
哪个组件是这种可视化模式的最佳选择?我试过 :
- p : editor : 我不想让工具栏可见。看来是隐藏不了了
- p:outputTextarea : html 由 p:editor 生成的标签在文本区域可见
- h: outputText : 渲染与 p:editor 略有不同,最重要的是,由于没有垂直滚动条,文本会溢出其容器。
我也尝试过使用 p:outputTextarea 进行编辑和可视化模式,但我会对 p:editor 中提供的更多工具感兴趣。
有什么想法吗?
<p:panel id="panelDG">
<p:dataGrid id="pdatagrid1" layout="grid" value="#{ib.bloc.groups}" var="group" columns="#{ib.bloc.groupsSize}" rowIndexVar="status">
<!-- other components -->
<p:panel styleClass="panel-textarea">
<s:account>
<p:editor id="editor1" value="#{ib.textArea1}" rendered="#{status == 0}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<p:editor id="editor2" value="#{ib.textArea2}" rendered="#{status == 1}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<p:editor id="editor3" value="#{ib.textArea3}" rendered="#{status == 2}" maxlength="4000" controls="bold italic underline strikethrough bullets outdent indent alignleft center alignright justify undo redo" />
<h:panelGrid >
<p:commandButton value="Save" action="#{ib.modifyGroupText(group)}" icon="ui-icon-disk" />
</h:panelGrid>
</s:account>
<s:guest>
<h:outputText value="#{group.textArea}" escape="false"></h:outputText>
</s:guest>
</p:panel>
</p:dataGrid>
</p:panel
.panel-textarea{
height: 500px;
}
如果你想隐藏 <p:editor>
的工具栏,因为用户没有编辑权限,你可以简单地使用 css.
Facelet
<p:editor styleClass="#{!login.editAccess ? 'hideToolbar' : ''}" disabled="#{!login.editAccess}" ... />
CSS
.hideToolbar .ui-editor-toolbar {
display: none;
}
哦,我还没有看到 .ui-editor-toolbar class !
否则,使用h:outputText时避免文本溢出:
.h-outputText{
display:block !important;
overflow-y: auto !important;
height: 400px !important;
}
感谢大家的回答