标签: components

将参数传递给struts2组件

我正在尝试使用freemarker创建一个struts2组件.我ftl用这样的代码创建了一个文件:

<script type="text/javascript" src="${parameters.library?default('')}"></script>
Run Code Online (Sandbox Code Playgroud)

期望一个名为library传递给组件的参数.如果参数不存在则默认为空白String.

在我的JSP页面上,我指的是这样的组件:

<s:component template="mytemplate.ftl">
    <s:param name="library" value="/scripts/mylibrary.js"/>
</s:component>
Run Code Online (Sandbox Code Playgroud)

不幸的是,没有设置library参数的值.它总是一片空白String.

我正在使用本教程中的建议,似乎s:param标记应该将参数传递给模板并使其可用.我在这里错过了什么?

有没有人有一些建立这些组件的经验可以解决一些问题?

谢谢.

templates components freemarker struts2

1
推荐指数
1
解决办法
4232
查看次数

在设置属性时更换事件的最优雅方法是什么?

做基于组件的开发,我发现自己经常这样做:

public class SomeClass
{
    SomeOtherClass foo;

    public SomeOtherClass Foo
    {
        get { return foo; }
        set {
            if (value != foo) {
                if (value != null) {
                    // subscribe to some events
                    value.SomeEvent += foo_SomeEvent;
                }

                if (foo != null) {
                    // unsubscribe from subscribed events
                    foo.SomeEvent -= foo_SomeEvent;
                }

                foo = value;
            }
        }
    }

    void foo_SomeEvent(object sender, EventArgs e)
    {
        // do stuff
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有更优雅的方式来做这个事件"换出"?

(当然,如果foo是不可变的话,可以避免整个问题,但是我不会得到任何视觉设计师的支持.)

c# events components event-handling

1
推荐指数
1
解决办法
175
查看次数

将指令插入组件事件

我想通过插入一个选项如何执行计时器的manny次数来扩展TTimer的功能.

我的问题是我需要在OnTimer()事件中执行此操作.有没有办法可以覆盖这个事件,从而保持原有的功能?

delphi components

1
推荐指数
1
解决办法
115
查看次数

组件可以用它自己的处理程序替换它的所有者表单的事件(OnClose)吗?

我正在研究一个放在我项目的每个形式上的组件.在运行时,是否可以让组件在其所有者表单的OnClose事件处理程序中包含代码.换句话说,表单将触发它自己的OnClose事件处理程序,但该组件还将包含在所有者表单的OnClose事件上运行的其他事件处理程序代码.(这就是所谓的矢量替换吗?)谢谢.

delphi components delphi-5

1
推荐指数
1
解决办法
639
查看次数

如何控制Components数组中的项目顺序?

我在Delphi中开发了一个带有TEdit组件的小应用程序.在此输入图像描述
我使用此函数来验证组件字段是否为空.

function TF_config.Validatefields:boolean;
var 
  i : integer;
begin
 for i := 0 to ComponentCount - 1 do
 begin
   if (Components[i]is TEdit) then
   begin
      if ((TEdit(Components[i]).Text) ='') then
      begin
        MessageDlg('Enter data in all the fields',mtWarning,[MBOK],0);
        TEdit(Components[i]).SetFocus;
        result := false;
        exit;
     end;             
   end;  //end for TEdit
 end;    //end component count 
 result := true;
end;
Run Code Online (Sandbox Code Playgroud)

现在我必须再添加一个组件
在此输入图像描述
如果有效,函数检查数据的顺序是 ID-> Name-> Address-> Phone-> Age.但我希望它是ID-> Name-> Address-> Age-> Phone.
我试图解决它删除手机编辑组件之后又加入之后将其添加年龄使用编辑component.Or 手机编辑组件年龄和增加新的编辑组件电话.这对于少数组件来说更容易,但是当拥有许多组件时变得乏味.所以我想知道我们是否可以以适合我们的方式安排组件.这可能吗?

delphi components

1
推荐指数
1
解决办法
1393
查看次数

组件的默认属性值

我想知道是否可以为组件定义默认属性值.
换句话说,我想在设计时为系统中的每个TDBGrid设置一个唯一的名称(可能是GUID),是否可能?
还有另一种方法可以控制在运行时和设计时都有效的组件的唯一性.在关闭delphi之后它也必须坚持下去; 例如,组合框列表值.

提前致谢!

编辑

下面是代码,不起作用:

type
  TMDBGrid = class(TDBGrid)
  private
    FUniqueName: String;
  protected
    function DefaultUniqueName: String;
    function GetUniqueName: String;
    procedure SetUniqueName(const AName: String);
  public
    constructor Create(AOwner: TComponent); override;
  published
    property UniqueName: String read GetUniqueName write SetUniqueName;
  end;

procedure Register;

implementation

uses uComponentUtils;

procedure Register;
begin
  RegisterComponents('MLStandard', [TMDBGrid]);
end;

{ TMDBGrid }

constructor TMDBGrid.Create(AOwner: TComponent);
begin
  inherited;
  FUniqueName := DefaultUniqueName;
end;

function TMDBGrid.DefaultUniqueName: String;
begin
  Result := GenerateGUID(True);
end;

function TMDBGrid.GetUniqueName: String;
begin
  Result := '';
end;

procedure TMDBGrid.SetUniqueName(const …
Run Code Online (Sandbox Code Playgroud)

delphi components properties delphi-7

1
推荐指数
1
解决办法
1508
查看次数

React-native:组件未渲染

我有一个地图组件,该组件会在调用以下方法时呈现:

render() {
    return (
      <MapComponents />
    )
  }
Run Code Online (Sandbox Code Playgroud)

但是,我想<MapComponents />从内部创建调用<View>,如下所示:

render() {
    return (
      <View>
      <MapComponents />
      </View>
    )
  }
Run Code Online (Sandbox Code Playgroud)

此时,我得到一个空白屏幕。任何想法为什么会这样?

maps components reactjs react-native airbnb-js-styleguide

1
推荐指数
1
解决办法
1777
查看次数

使用Angular 4和Bootstrap 4将页脚设置在底部(适合内容)

¿我如何使页脚停留在具有以下结构的网站底部?

<html>
    <head>
    </head>

    <body>
        <app-root></app-root>
    </body>

</html>
Run Code Online (Sandbox Code Playgroud)

因此,app-root是angular中的主要组件,在该组件内部,我具有以下结构:

<app-navbar></app-navbar>
<div class="container">
    <div class="row">

        <div class="col-12 p-0">
            <app-information *ngIf="title == 'information'"></app-information>
            <app-form *ngIf="title == 'form'"></app-form> 
            <app-proyects *ngIf="title == 'proyects'"></app-proyects>
            <app-blog *ngIf="title == 'blog'"></app-blog>
            <app-courses *ngIf="title == 'coursess'"></cursos>
        </div>

    </div>
</div>
<app-footer></app-footer>
Run Code Online (Sandbox Code Playgroud)

因此,仅出于理解目的,显示col-12 div内的div取决于一个变量,该变量是通过按导航栏上的按钮设置的标题。情况是,并非所有这些div的内容都超过了屏幕大小,并且页脚向上。

在页脚内部,我具有以下结构:

<footer class="bg-inf-blue" >
    <div class="container p-0">
        <div class="row text-white py-3">
            <div class="col-6 h6 p-0">Contact</div>
            <div class="col-6 h6">Social Media</div>
            <div class="col-2 p-0">
                <ul class="list-unstyled">
                    <li class="h6">Place 1</li>
                    <li>Place 1 address</li>
                    <li>XXX XXX-XXXX</li>
                </ul>
            </div>
            <div class="col-2">
                <ul …
Run Code Online (Sandbox Code Playgroud)

components footer twitter-bootstrap bootstrap-4 angular

1
推荐指数
1
解决办法
1万
查看次数

ComponentWillMount仅在第一次触发?

MainComponent:

<Tabs 
  initialPage={this.props.day}
  tabBarUnderlineStyle={{ backgroundColor: '#5AF158' }} 
  renderTabBar={() => <ScrollableTab />}>
  {this.renderTabHeader()}
</Tabs>

renderTabHeader() {
  return (
    this.props.dateArray.map((date, i) => 
      <Tab 
        key={i}
        heading={date.format('DD/MM')} 
        tabStyle={styles.tabStyling} 
        activeTabStyle={styles.activeTabStyle} 
        textStyle={styles.tabTextStyle} 
        activeTextStyle={styles.activeTabTextStyle} 
      >
        <View style={{ backgroundColor: '#EEEEEE', flex: 1 }}>
          <Content contentDate={date.format('YYYY-MM-DD')} />
        </View>
      </Tab>
    )
  );
}
Run Code Online (Sandbox Code Playgroud)

内容组件:

class Content extends Component {
  componentWillMount() {
    console.log('Component Will Mount() ?');
    this.props.loadTransactionByDate({ date: this.props.contentDate });
  }

render() {
  return (
    <View><Text>{this.props.contentDate}</Text></View>
  );
  }
Run Code Online (Sandbox Code Playgroud)

基本上,在MainComponent中有一组选项卡.我注意到一些相当奇怪的东西Content会在他们的标签第一次点击或激活时安装?

这是第一次的意思,我们可以点击Tab索引2并看到控制台登录componentWillMount,然后我们切换到另一个选项卡,如果再次返回Tab索引2,componentWillMount将不再被触发?

lifecycle components react-native native-base

1
推荐指数
1
解决办法
2729
查看次数

React-Router不会在不同路径上重新安装组件

我的应用程序中有一个组件是一种形式。该表格用于创建新许可证或编辑现有许可证。无论哪种方式,它都是一个组件,并检查componentDidMount()是哪个“ pageType”(添加/更新)。现在我要解决的问题是,当我使用表单来编辑许可证(被许可人/:id /编辑),并且单击作为坐浴盆的按钮来创建新许可证(被许可人/添加)时,它不会重新安装零件。它将更改URL,但所有预加载的数据仍处于表单中。

  LicenseeForm = Loadable({
    loader: () => import('./license/LicenseeForm'),
    loading: 'Loading..'
  });

render() {
    return (
      <Router>
        <Switch>
          <LoginRoute exact path="/" component={this.LoginView}/>
          <LoginRoute exact path="/login" component={this.LoginView}/>
          <PrivateRoute exact path="/licensees/add" component={this.LicenseeForm}/>
          <PrivateRoute exact path="/licensees/:id/update" component={this.LicenseeForm}/>
          <Route path="*" component={this.NotFoundPage}/>
        </Switch>
      </Router>
    )
  }

const PrivateRoute = ({component: Component, ...rest}) => (
  <Route
    {...rest}
    render={props =>
      authService.checkIfAuthenticated() ? (<Component {...props} />) :
        (<Redirect
            to={{
              pathname: "/login",
              state: {from: props.location}
            }}/>
        )
    }
  />
);
Run Code Online (Sandbox Code Playgroud)

零件:

componentDidMount() {
    const locationParts = this.props.location.pathname.split('/');
    if …
Run Code Online (Sandbox Code Playgroud)

javascript components reactjs react-router

1
推荐指数
1
解决办法
1072
查看次数