You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ADF中实现af:inputText可调整大小?及弹窗文本截断问题

解决ADF af:inputText的两个布局问题

针对你遇到的两个af:inputText相关问题,我整理了具体的解决方案:

1. 让af:inputText支持拖拽调整大小

把inputText放在af:panelStretchLayout里并不能直接让它支持可调整大小——这个布局组件主要是用来拉伸区域适配容器,不是负责输入框的尺寸调整。要实现拖拽调整,你需要给inputText添加CSS resize属性,具体做法如下:

修改你的inputText代码,添加inline style设置resize规则:

<af:inputText rendered="#{bindings.commentType1.inputValue eq 'out'}" 
              autoSubmit="true" 
              simple="true" 
              value="#{bindings.newCommentValue.inputValue}"
              style="resize: both; min-width: 200px; min-height: 50px;"/>
  • resize: both:允许用户同时调整宽度和高度;如果只需要垂直调整,改成resize: vertical即可
  • min-width/min-height:避免输入框被缩得太小影响使用

2. 修复弹窗中disabled inputText文本截断、无法自适应的问题

disabled状态的inputText默认会受columns属性限制宽度,且不会自动换行,导致文本截断。可以通过以下两种方式解决:

方案一:调整inputText属性让它自适应

修改代码,添加换行设置并优化宽度样式:

<af:inputText disabled="true" 
              value="#{bindings.CrOuputComments.inputValue}" 
              simple="true" 
              rendered="#{bindings.commentType1.inputValue eq 'out'}" 
              required="#{bindings.CrOuputComments.hints.mandatory}"
              wrap="soft"  <!-- 开启自动换行 -->
              rows="3"     <!-- 设置初始显示行数 -->
              style="width: 100%; max-width: 400px;"  <!-- 占满容器宽度,限制最大宽度 -->
              maximumLength="#{bindings.CrOuputComments.hints.precision}" 
              shortDesc="#{bindings.CrOuputComments.hints.tooltip}" 
              id="it39">
    <f:validator binding="#{bindings.CrOuputComments.validator}"/>
</af:inputText>

注意:去掉columns="#{bindings.CrOuputComments.hints.displayWidth}"这个属性,它会固定输入框的列数,导致宽度无法自适应。

方案二:改用af:outputText展示内容(更推荐)

既然inputText是disabled状态,本质是用来展示内容而非输入,改用af:outputText会更适配自适应需求:

<af:outputText value="#{bindings.CrOuputComments.inputValue}" 
               simple="true" 
               rendered="#{bindings.commentType1.inputValue eq 'out'}"
               style="white-space: pre-wrap;"/>
  • white-space: pre-wrap:保留文本中的换行和空格,同时自动换行,完美适配长文本展示

内容的提问来源于stack exchange,提问作者osfar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:34:19