name binding of webshpere

本文介绍了如何在web.xml配置文件中使用新名称部署资源,并调整相关引用,包括数据源和EJB名称变更。

Use a new name to deploy the resource

 

web.xml

	<resource-ref id="ResourceRef_1234567890123">
		<description></description>
		<res-ref-name>jdbc/xxxDataSource</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
		<res-sharing-scope>Shareable</res-sharing-scope>
	</resource-ref>

 

ibm-web-ext.xmi

ibm-web-bnd.xmi

<resRefBindings xmi:id="ResourceRefBinding_1234567890124" jndiName="jdbc/xxxNewDataSource">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1234567890123"/>
  </resRefBindings>
 

ResourceRef_1234567890123 , jdbc/xxxDataSource-->jdbc/xxxNewDataSource

 

ejb-jar.xml

<session id="xxxId">
         <ejb-name>xxxName</ejb-name>
</session>

 

ibm-ejb-jar-bnd.xmi

<ejbBindings xmi:id="xxxbindId" jndiName="ejb/xxxNewName">
    <enterpriseBean xmi:type="ejb:Session" href="META-INF/ejb-jar.xml#xxxId"/>
</ejbBindings>
 

xxxId, xxxName-->ejb/xxxNewName

 

ctx.lookup("java:cmp/env/xxxEnvEntryName");  

### 绑定动态属性 `Name` 到 WPF `TextBox` 在 WPF 中,若需将 `TextBox` 绑定到一个对象的动态属性 `Name`,可通过数据绑定机制实现。该机制允许 UI 元素与数据源之间保持同步,并在数据源发生变化时自动更新界面。 #### 实现方式 首先定义一个包含 `Name` 属性的类作为数据源: ```csharp public class Data { public string Name { get; set; } } ``` 在窗口或用户控件中,通过代码设置绑定关系: ```csharp public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var data = new Data { Name = "Q.yuhen" }; BindingOperations.SetBinding( this.textBox1, TextBox.TextProperty, new Binding("Name") { Source = data }); } } ``` 上述代码创建了一个 `Data` 实例,并将其 `Name` 属性绑定到 `TextBox` 的 `Text` 属性上。当 `Name` 值发生变化时,`TextBox` 会自动更新以反映最新值[^1]。 #### XAML 中的绑定表达式 也可以在 XAML 文件中直接声明绑定关系,前提是设置了合适的 `DataContext`: ```xml <Window x:Class="WpfApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="300" Width="400"> <StackPanel Margin="10"> <TextBox Text="{Binding Name}" Width="200"/> </StackPanel> </Window> ``` 在对应的代码文件中设置 `DataContext`: ```csharp public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var data = new Data { Name = "Q.yuhen" }; DataContext = data; } } ``` 这种方式更符合 MVVM 模式,便于分离界面逻辑与业务逻辑。 #### 动态更新支持 若希望在运行时更改 `Name` 属性并通知 UI 更新,应实现 `INotifyPropertyChanged` 接口: ```csharp public class Data : INotifyPropertyChanged { private string name; public string Name { get => name; set { if (name != value) { name = value; OnPropertyChanged(); } } } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } ``` 这样,每次修改 `Name` 属性时,绑定的 `TextBox` 都会自动刷新显示新值。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值