可以说我有一个javascript对象数组,我试图将这些对象传递给php页面以将它们保存到数据库中.我没有问题将变量传递给php并在该变量上使用$ _POST ["entries"],但我无法弄清楚如何传递整个对象数组,因此我可以访问我的objects.entryId和.mediaType值在php页面上.
哦,在任何人问之前,是的,我需要这样做的原因是因为我有一个flash上传器,你猜对了..上传到CDN服务器(远程),远程服务器只回复这样的js对象.
感谢任何人都能提供的帮助.
这是我的JS功能:
function test() {
entriesObj1 = new Object();
entriesObj1.entryId = "abc";
entriesObj1.mediaType = 2;
entriesObj2 = new Object();
entriesObj2.entryId = "def";
entriesObj2.mediaType = 1;
var entries = new Array();
entries[0] = entriesObj1;
entries[1] = entriesObj2;
var parameterString;
for(var i = 0; i < entries.length; i++) {
parameterString += (i > 0 ? "&" : "")
+ "test" + "="
+ encodeURI(entries[i].entryId);
}
xmlhttp.open("POST","ajax_entries.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", parameterString.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = handleServerResponseTest;
xmlhttp.send(parameterString);
}
function …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用xs:key和xs:keyref定义在XML模式上定义一些外键约束.我希望文档的结构按以下方式分层:
<?xml version="1.0" encoding="UTF-8"?>
<tns:root xmlns:tns="http://www.example.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/ SampleSchema.xsd ">
<parent parentKey="parent1">
<child childKey="child1"/>
<child childKey="child2"/>
</parent>
<parent parentKey="parent2">
<child childKey="child1"/>
<child childKey="child2"/>
</parent>
<referrer parentRef="parent1" childRef="child2"/>
</tns:root>
Run Code Online (Sandbox Code Playgroud)
每个父节点都有一个(全局)唯一键,由parentKey定义.每个子项都有由childKey定义的键,但是childKey仅在其包含父项的范围内是唯一的.
然后是一个引用者列表,其中包含对特定父和子的外键引用.
我可以根据需要定义键,只需将它们放在正确的元素上:根元素上的parentKey约束和父元素上的childKey约束.我也可以毫无困难地将keyref定义为parentKey.
尝试为childKey定义keyref时出现问题.我尝试在root元素上定义一个简单的keyref到childKey,但是这不起作用,因为我看不到只选择正确父子树下的子元素.(Eclipse验证器,至少,总是简单地验证文档中最后一个父子树的内容......).
然后我尝试定义一个复合键(在root上),用:
如果父项下定义了多个子项,则会失败.这是基于XSD 1.1规范 3.11.4节第3项的正确行为,该规则指出密钥必须与每个字段定义最多匹配一个节点.
重申一下:如果我强迫childKeys全球独一无二,这很容易实现; 困难在于引用本地唯一的childKeys.
任何XSD大师都有想法吗?
作为参考,这是一个示例XSD,注释掉了一个失败的childKey keyref:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/" xmlns:tns="http://www.example.org/" elementFormDefault="unqualified">
<element name="root">
<complexType>
<sequence>
<element name="parent" maxOccurs="unbounded" minOccurs="1">
<complexType>
<sequence>
<element name="child" maxOccurs="unbounded" minOccurs="1"> …Run Code Online (Sandbox Code Playgroud) 基本上我有这个
@implementation MyView : CPView
{
CPArray MyPanelArray;
}
// Populate the MyPanelArray and position each panel
- (void)initMyView
{
...
}
Run Code Online (Sandbox Code Playgroud)
MyPanels几乎是图像的包装器.当一切都被初始化时,它就会很好.然后我有一个滑块来操纵图像的位置,我知道如何重绘所有内容的唯一方法是用新实例覆盖MyView并在主内容中执行类似的操作
// Has the correct effect, but feels wrong
- (void)sliderAction:(id)sender
{
var myNewView = [MyView initWithPositionValue:[sender value]];
[_contentView replaceSubview:_myView with:myNewView];
_myView = myNewView;
}
Run Code Online (Sandbox Code Playgroud)
它可以正常工作,但我怀疑这是"正确的方法".
*我知道我可以使用CPCollectionView进行基本设置,但它不能用于我想要完成的任务.
提前致谢.
我有一个包含asp:Literal的用户控件.
<div>
<asp:Literal id="MenuContainer" runat="server" />
</div>
Run Code Online (Sandbox Code Playgroud)
代码隐藏页面中有一个初始化控件的方法:
internal void Setup(MyBusinessObject obj)
{
MenuObject menu = MenuHelper.GetMenu(obj.State);
if(obj == null)
MenuContainer.Visible = false;
//other code
}
Run Code Online (Sandbox Code Playgroud)
在使用控件的页面中,我在LoadComplete事件处理程序中调用控件的Setup方法(我在Load事件中首先调用它).无论MyBusinessObject为null还是非null,当我在用户控件上访问Literal时,我都会收到错误:
Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)
是什么原因以及对此有何补救措施?
我只是想知道什么是更昂贵的,例如:
echo "Hello world, my name is $name";
Run Code Online (Sandbox Code Playgroud)
要么
echo 'Hello world, my name is '.$name;
Run Code Online (Sandbox Code Playgroud)
我知道在这种情况下它不会有太大的区别,但也许在这里它会:
for($i = 0; $i < 10000; $i++)
{
echo 'Hello world, my name is '.$name;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我知道我可以使用Graphics.CopyFromScreen()获取整个屏幕的屏幕截图.但是,如果我只想要特定应用程序的屏幕截图怎么办?
我最近做了一个编程任务,要求我们在代码中实现一个由UML图指定的程序.有一次,该图指定我必须创建一个显示计数(从1开始)的匿名JButton,并在每次单击时递减.JButton及其ActionListener都必须是匿名的.
我提出了以下解决方案:
public static void main(String[] args) {
JFrame f = new JFrame("frame");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 400);
f.getContentPane().add(new JButton() {
public int counter;
{
this.counter = 1;
this.setBackground(Color.ORANGE);
this.setText(this.counter + "");
this.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
counter --;
setText(counter + "");
}
});
}
});
f.setVisible(true);
}Run Code Online (Sandbox Code Playgroud)
这会添加一个匿名的JButton,然后添加另一个(内部)匿名ActionListener来处理事件并根据需要更新按钮的文本.有更好的解决方案吗?我很确定我不能宣布匿名JButton implements ActionListener (),但还有另一种更优雅的方法来实现相同的结果吗?
我正在使用Window Service项目.必须在序列时间内将数据写入Excel文件中的工作表.
但有时,有时候,服务会在尝试获取带有单元名称的范围时抛出异常"HRESULT异常:0x800A03EC".
我已经打开excel表的代码,并在这里获取单元格.
1:打开excel表
m_WorkBook = m_WorkBooks.Open(this.FilePath, 0, false, 5,
"", "", true, Excels.XlPlatform.xlWindows, ";",
true, false, 0, true, 0, 0);
Run Code Online (Sandbox Code Playgroud)
2:让单元格写入
protected object m_MissingValue = System.Reflection.Missing.Value;
Range range = m_WorkSheet.get_Range(cell.CellName, m_MissingValue);
// error from this method, and cell name is string.
Run Code Online (Sandbox Code Playgroud) 我有一个Windows窗体自定义控件,它像一个面板,它可以包含任意数量的子窗口.子控件的数量和类型是在运行时确定的,因此我需要以通用方式工作,而不知道可能存在或可能不存在的确切子控件.
我想根据面板是否包含焦点来改变面板的背景颜色.因此,如果面板的孩子(或面板的孩子的孩子等......)获得焦点我想知道这一点,所以我可以更新自定义面板的背景颜色.当焦点转移到不在子层次结构中的某些东西时,我也需要知道所以我可以恢复到原始背景颜色.
Control.ContainsFocus非常适合告诉我面板是否包含子层次结构中的焦点,但我需要知道何时发生更改.目前我只能提出以下不良机制.
我挂钩每个孩子的GotFocus/LostFocus和每个孩子的每个孩子等.我还必须挂钩ControlAdded/ControlRemoved以确保我与可能的改变孩子hieararchy保持同步.正如你所看到的,这可能最终导致很多事件挂钩,我怀疑必须有一个更简单的方法.有任何想法吗?