在服务器处理请求时,我想向客户端显示一个模式窗口,这将阻止他继续单击按钮。
这些机制一般是如何实施的,它们基于什么?如何理解窗口显示持续时间?请说明是谁干的。
在服务器处理请求时,我想向客户端显示一个模式窗口,这将阻止他继续单击按钮。
这些机制一般是如何实施的,它们基于什么?如何理解窗口显示持续时间?请说明是谁干的。
由于连接速度较低,用户有时间在客户端执行大量操作,而服务器则处理第一个操作。
如何解决这个问题?是否有可能以某种方式忽略请求,直到第一个请求完成?排个队,大概这样的问题一般是怎么解决的,请告诉我。
例如,我们设置 size LinkedBlockingQueue= 2。当我们尝试放入第三个元素时,尝试放入数据的线程挂起。如何使当您尝试放入第三个元素时,删除最旧的元素,并将新元素添加到队列中。
也许这甚至有一个特殊的队列?
我需要获取客户端的时区才能将其传递给页面上的组件参数。该页面使用一个 bean,它使用 EL 表达式从该 bean 接收数据。如何获取服务器时区,我知道:
TimeZone.getDefault()
如何在客户端获取时区(我需要时区 ID):
new Date().toTimeString().split('(')[1].toString().replace(')','');
value但我不知道如何将客户端时区 ID 的值传递给 bean(或者,也许,立即在 bean 中获取),或者直接传递给组件。请提出任何选择。
我使用它连接脚本<h:outputScript name="js/js-file.js" library="java" />在整个项目中(在每个页面上)都是可见的。并在没有使用的页面弹出:
类型错误:XXX 未定义
如何限制此脚本在特定页面上的可见性?例如,仅在page1.xhtml.
意思就是h:outputScript把整个项目写在一个地方,这样的脚本有很多。有什么办法可以控制他们的可见性吗?
问题是:
<p:ajax event="select" listener="#{bean.onSelect}" oncomplete="xxx(#{bean.m})" />
事件处理程序select从所选元素中检索参数m,然后函数接受该参数xxx。但是,正如你所理解的,oncomplete它被调用得更早,并且字段m被拉空了。如何解决这个问题?有没有可能以某种方式抛出jsf中的select事件,然后直接转到客户端?还是有更优雅的解决方案?
感谢 allowTypes,我只禁止上传非“docx|xml|json”类型的文件。是否有可能以某种方式添加一个掩码,该掩码将仅在对话框中显示诸如“docx|xml|json”之类的文件,而不是全部?
<p:fileUpload value="#{mainBean.uploadedFilesList}"
allowTypes="/(\.|\/)(docx|xml|json)$/"/>
我需要在页面上提供两种语言(英语、俄语)的支持。
据我了解,我需要在资源包中创建 translate.properties、translate_en.properties、translate_ru.properties。
接下来,我将 files = files 和 files = files 写入它们
现在。我如何利用它来提供两种语言?据我所知,我需要创建一个按钮来更改网站上的语言,并从中获取一个键值(显示哪种语言),并以某种方式将其与标记链接在一起。
<p:layou>
<p:layoutUnit>
<h3>files</h3>
</p:layoutUnit>
</p:layout>
我怀疑课堂上还需要写一些别的东西。请帮助我了解整个行动链。
http://javastudy.ru/jsf-2/jsf-hello-world-example-primefaces/
我按照这个例子做了所有的事情,但是当我运行“localhost: 8080”时,它给出了 404 错误。
显示正常的html页面,但没有显示jsf。
我在网上看了很多例子,我做的都对,可能是什么问题,请告诉我?好吧,您可以阅读相关信息的建议也很合适:)
传递数据时,我调用递归并用完堆栈,原因如下:
类有需要传递给类的Controller_MainForm变量public int cordX, cordY;Raket
这是我正在尝试做的事情:
class Raket
{
Controller_MainForm control;
public Raket()
{
control = new Controller_MainForm();
x = control.cordX;
y = control.cordY;
}
但是在类方法中创建Controller_MainForm了类的实例Model
public partial class Controller_MainForm : Form
{
View view;
Model model;
public int cordX, cordY;
Thread modelGo;
public Controller_MainForm() : this(850) { }
public Controller_MainForm(int sizeField) : this(sizeField, 1) { }
public Controller_MainForm(int sizeField, int amountRaket) : this(sizeField, amountRaket, 1) { }
public Controller_MainForm(int sizeField, int amountRaket, int amountAero) : this(sizeField, amountRaket, amountAero, 40) { }
public Controller_MainForm(int sizeField, int amountRaket, int amountAero, int speedGame)
{
InitializeComponent();
model = new Model(sizeField, amountAero, amountRaket, speedGame);
view = new View(model);
this.Controls.Add(view);
cordX = Convert.ToInt32(textBox1.Text);
cordY = Convert.ToInt32(textBox2.Text);
}
private void Start_Click(object sender, EventArgs e)
{
if (model.gameStatus == GameStatus.stoping)
{
model.gameStatus = GameStatus.playing;
modelGo = new Thread(model.Go);
modelGo.Start();
view.Invalidate();
}
}
private void Controller_MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (modelGo != null)
{
model.gameStatus = GameStatus.stoping;
modelGo.Abort();
}
DialogResult dr = MessageBox.Show("Закрыть приложение?" , "Radionavig_24", MessageBoxButtons.YesNoCancel);
if (dr == DialogResult.Yes)
e.Cancel = false;
else
e.Cancel = true;
}
}
在模型类中,方法:
class Model
{
int sizeField;
int amountRaket;
int amountAero;
public int speedGame;
public GameStatus gameStatus;
public Raket raket;
public Model(int sizeField, int amountRaket, int amountAero, int speedGame)
{
this.sizeField = sizeField;
this.amountAero = amountAero;
this.amountRaket = amountRaket;
this.speedGame = speedGame;
raket = new Raket();
gameStatus = GameStatus.stoping;
}
public void Go()
{
while (gameStatus == GameStatus.playing)
{
Thread.Sleep(speedGame);
raket.Run();
}
}
}
并再次创建一个实例,new Raket()如此循环。如何在不递归的情况下传递数据?Raket()Controller_MainForm
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] arg)
{
Controller_MainForm cm;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
switch (arg.Length)
{
case 0: cm = new Controller_MainForm(); break;
case 1: cm = new Controller_MainForm(Convert.ToInt32(arg[0])); break;
case 2: cm = new Controller_MainForm(Convert.ToInt32(arg[0]), Convert.ToInt32(arg[1])); break;
case 3: cm = new Controller_MainForm(Convert.ToInt32(arg[0]), Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2])); break;
case 4: cm = new Controller_MainForm(Convert.ToInt32(arg[0]), Convert.ToInt32(arg[1]), Convert.ToInt32(arg[2]), Convert.ToInt32(arg[3])); break;
default: cm = new Controller_MainForm(); break;
}
Application.Run(cm);
}
}
我想实现:按钮排列成正方形(作为二维 NxN 数组)。单击按钮时,将旋转一行和一列中的所有按钮。数字 N 是可定制的。一开始我什么都做MainWindow.xaml.cs,他们建议我正常做一切并使用它MVVM。代码MainWindow.xaml.cs:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private Button[,] CreateButtons(int quantity)
{
Form.Rows = quantity;
Form.Columns = quantity;
Button[,] buttons = new Button[quantity, quantity];
for (int i = 0; i < quantity; i++)
{
for (int j = 0; j < quantity; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Width = 100;
buttons[i, j].Height = 20;
buttons[i, j].Margin = new Thickness(5,80,0,0);
buttons[i, j].Click += new RoutedEventHandler(new_button_click);
}
}
return buttons;
}
void new_button_click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
if (btn != null)
{
var rotateTransform = btn.RenderTransform as RotateTransform;
var transform = new RotateTransform(90 + (rotateTransform == null ? 0 : rotateTransform.Angle));
transform.CenterX = 50;
transform.CenterY = 10;
btn.RenderTransform = transform;
}
}
private void AddToWrapPanel(int quantity, Button[,] buttons)
{
for (int i = 0; i < quantity; i++)
for (int j = 0; j < quantity; j++)
{
Form.Children.Add(buttons[i, j]);
}
}
private int GetQuantityButtons()
{
ComboBoxItem item = (ComboBoxItem)comboBox1.SelectedItem;
int count = int.Parse((string)item.Content);
return count;
}
private void СreateButton_Click(object sender, RoutedEventArgs e)
{
if (Form.Children.Count > 0)
Form.Children.Clear();
int count = GetQuantityButtons();
Button[,] buttons = CreateButtons(count);
AddToWrapPanel(count, buttons);
}
}
现在我开始移动所有东西。
XAML:
<Window x:Class="Di.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:user="clr-namespace:Di"
Title="Сейф" Height="715.6" Width="840" Left="250" Top="10" Background="Silver" ResizeMode="CanMinimize"
TextOptions.TextFormattingMode="Display" Icon="Resources/Icon1.ico">
<Window.DataContext>
<user:MainWindowModel />
</Window.DataContext>
<Grid>
<ItemsControl Margin="0,30,0,0">
<UniformGrid x:Name="Form"/>
<WrapPanel Name="wrapPanel" Background="#FFF2F2F2" />
</ItemsControl>
<Button Content="Старт" Height="23" HorizontalAlignment="Left" Margin="457,12,0,0" Name="createButton" VerticalAlignment="Top" Width="75" Click="СreateButton_Click" Command="{Binding Seter}" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="368,12,0,0" Name="comboBox1" VerticalAlignment="Top" Width="74" SelectedIndex="0" RenderTransformOrigin="0.5,0.739">
<ComboBoxItem Content="{Binding Three}" />
<ComboBoxItem Content="{Binding Four}" />
<ComboBoxItem Content="{Binding Five}" />
<ComboBoxItem Content="{Binding Six}" />
</ComboBox>
<Label Content="{Binding Lvl}" HorizontalAlignment="Left" Margin="254,10,0,0" VerticalAlignment="Top"/>
</Grid>
代码VM:
public class MainWindowModel
{
public int Three { get; set; }
public int Four { get; set; }
public int Five { get; set; }
public int Six { get; set; }
public string Lvl { get; set; }
public MainWindowModel()
{
Three = 3;
Four = 4;
Five = 5;
Six = 6;
Lvl = "Сложность (3 - 6):";
}
private ICommand _seter;
public ICommand Seter
{
get
{
return _seter ?? (_seter = new RelayCommand(() =>
{
// действие при вызове команды
}));
}
}
}
到目前为止,只有这样.. 请帮助我转移并完成我计划的时刻。例如:如何VM在服务按钮中创建一个属性RotationAngle?单击“创建”然后使用它们时如何生成一组按钮?如何访问UniformGrid行数和列数并将其与所选中int的关联combobox?
按钮是这样生成的:
private Button[,] CreateButtons(int quantity)
{
Form.Rows = quantity;
Form.Columns = quantity;
Button[,] buttons = new Button[quantity, quantity];
for (int i = 0; i < quantity; i++)
{
for (int j = 0; j < quantity; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Width = 100;
buttons[i, j].Height = 20;
buttons[i, j].Margin = new Thickness(5,80,0,0);
buttons[i, j].Click += new RoutedEventHandler(new_button_click);
}
}
return buttons;
}
他们有一个点击事件处理程序:
void new_button_click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
if (btn != null)
{
var transform = new RotateTransform(90);
transform.CenterX = 50;
transform.CenterY = 10;
btn.RenderTransform = transform;
}
}
如何实现当您单击一个按钮时,一行和一列中的所有按钮都会旋转。
我想在点击时旋转按钮。认为它应该像这样工作:
void new_button_click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
var transform = btn.RenderTransform as RotateTransform;
transform.Angle += 90;
}
但它不起作用))怎么了?我想用 C# 代码而不是 XAML 实现旋转。单击时,它会在这一行发誓:
transform.Angle += 90;
例外:
对象引用不指向对象的实例。
有一个按钮点击事件:
void new_button_click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
btn.?
}
我希望按钮在单击时旋转 90 度。如何实施?
我需要在窗体上创建可转动的手柄(单击鼠标,手柄的位置从垂直变为水平,反之亦然)。句柄排列成正方形,就像一个二维 NxN 数组。数字 N 必须是可定制的。我决定创建一个旋转按钮数组。
private Button[,] CreateButtons(int quantity)
{
Button[,] buttons = new Button[quantity, quantity];
for (int i = 0; i < quantity; i++)
{
for (int j = 0; j < quantity; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Width = 50;
buttons[i, j].Height = 20;
buttons[i, j].VerticalAlignment = System.Windows.VerticalAlignment.Top;
buttons[i, j].HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
buttons[i, j].Margin = new Thickness(10);
}
}
return buttons;
}
private void AddToWrapPanel(int quantity, Button[,] buttons)
{
for (int i = 0; i < quantity; i++)
for (int j = 0; j < quantity; j++)
{
wrapPanel.Children.Add(buttons[i, j]);
}
}
private int GetQuantityButtons()
{
ComboBoxItem item = (ComboBoxItem)comboBox1.SelectedItem;
int count = int.Parse((string)item.Content);
return count;
}
private void СreateButton_Click(object sender, RoutedEventArgs e)
{
if (wrapPanel.Children.Count > 0)
wrapPanel.Children.Clear();
int count = GetQuantityButtons();
Button[,] buttons = CreateButtons(count);
AddToWrapPanel(count, buttons);
}
这就是我所拥有的。但问题出在脸上——所有的按钮都排成一排。如何实现矩阵布局?