我想让我的User对象都具有相同的基本行为,为此我需要向Anonymous User添加几个方法/属性.
我已经将User子类化为更丰富的用户对象,但我想知道是否有人对匿名用户做了同样的事情?如果有任何首选方式!
为什么导入org.apache.commons.lang.StringUtils默认情况下不能在android中导入.
我是否必须包含外部库?那我在哪里可以找到网上的图书馆?
package com.myapps.urlencoding;
import android.app.Activity;
import org.apache.commons.lang.StringUtils;
public class EncodeIdUtil extends Activity {
/** Called when the activity is first created. */
private static Long multiplier=Long.parseLong("1zzzz",36);
/**
* Encodes the id.
* @param id the id to encode
* @return encoded string
*/
public static String encode(Long id) {
return StringUtils.reverse(Long.toString((id*multiplier), 35));
}
/**
* Decodes the encoded id.
* @param encodedId the encodedId to decode
* @return the Id
* @throws IllegalArgumentException if encodedId is not …Run Code Online (Sandbox Code Playgroud) 我正在运行带有FreeBSD TCP/IP堆栈的eCos.让两个线程运行一个从一个套接字读取而一个线程写入同一个套接字是否安全?
嗯,我想因为它的FreeBSD堆栈操作系统并不重要.
最好的祝福,
弗里德里希
为什么JPA需要域对象的无参数构造函数?我正在使用eclipselink并在部署期间遇到此异常.
Exception [EclipseLink-63] (Eclipse Persistence Services-1.1.0.r3639-SNAPSHOT):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The instance creation method
[com.me.model.UserVO.<Default Constructor>], with no parameters,
does not exist, or is not accessible.
Internal Exception: java.lang.NoSuchMethodException:
com.me.model.UserVO.<init>()
Descriptor: RelationalDescriptor(com.me.model.UserVO -->
[DatabaseTable(user)])
Run Code Online (Sandbox Code Playgroud) 我正在尝试开发Windows Mobile 6(在WF/C#中)应用程序.只有一个表单,表单上只有一个PictureBox对象.在它上面我绘制所有想要的控件或我想要的任何东西.
我正在做两件事.绘制自定义形状并从.png文件加载位图.
下一行在加载时锁定文件(这是一种不受欢迎的情况):
Bitmap bmp = new Bitmap("file.png");
Run Code Online (Sandbox Code Playgroud)
所以我使用另一种方式加载位图.
public static Bitmap LoadBitmap(string path) {
using (Bitmap original = new Bitmap(path))
{
return new Bitmap(original);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我想要慢得多,但我不知道有什么更好的方法来加载图像,同时快速释放文件锁.
现在,在绘制图像时,我使用的方法是:
public void Draw() {
Bitmap bmp = new Bitmap(240,320);
Graphics g = Graphics.FromImage(bmp);
// draw something with Graphics here.
g.Clear(Color.Black);
g.DrawImage(Images.CloseIcon, 16, 48);
g.DrawImage(Images.RefreshIcon, 46, 48);
g.FillRectangle(new SolidBrush(Color.Black), 0, 100, 240, 103);
pictureBox.Image = bmp;
}
Run Code Online (Sandbox Code Playgroud)
然而,这似乎是某种内存泄漏.如果我继续这么做,应用程序最终会崩溃.
因此,我有3个问题:
1.)在不锁定文件的情况下从文件加载位图的更好方法是什么?
2.)需要在Draw()函数中手动处理哪些对象(以及以何种顺序),因此没有内存泄漏且没有抛出ObjectDisposedException?
3.)如果pictureBox.Image设置为bmp,就像代码的最后一行一样,pictureBox.Image.Dispose()只会处理与维护pictureBox.Image或底层Bitmap相关的资源吗?
我有一个MySQL数据库,从中创建一个视图.是否可以为视图中的每一行添加自动递增ID?
我试过了
CREATE ALGORITHM=UNDEFINED DEFINER=`database_name`@`%` SQL SECURITY DEFINER VIEW `MyView` AS
set @i = 0;
select @i:=@i+1 as `id`
...
Run Code Online (Sandbox Code Playgroud)
但这在视图中不起作用.
我有TextBox一个Panel,我想通知时的"文本框"的值更改.
我尝试过以下事件处理程序:
ChangeHandlerValueChangeHandlerKeyPresshandler我的问题是,ValueChangeHandler与ChangeHandler只有火的时候焦点离开控件.该KeyPressHandler火灾正确,但之前TextBox自己已经看到的情况下,这意味着将呼叫getText()从我的事件处理程序中看到一个不完整的数值.
是否有将工作完全一样的事件KeyPressHandler,但被解雇后的TextBox曾见过的事件吗?
编辑:在Windows XP上的Chrome和IE8中可以看到此行为
如果我想使用我的Web应用程序跟踪每个客户端的会话状态,这是一个更好的选择 - 会话Bean还是HTTP会话 - 要使用?
//request is a variable of the class javax.servlet.http.HttpServletRequest
//UserState is a POJO
HttpSession session = request.getSession(true);
UserState state = (UserState)(session.getAttribute("UserState"));
if (state == null) { //create default value .. }
String uid = state.getUID();
//now do things with the user id
Run Code Online (Sandbox Code Playgroud)
在ServletContextListener的实现中注册为Web应用程序监听器WEB-INF/web.xml:
//UserState NOT a POJO this this time, it is
//the interface of the UserStateBean Stateful Session EJB
@EJB
private UserState userStateBean;
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext …Run Code Online (Sandbox Code Playgroud) 我有一个非常棘手的问题:
我正在使用ListView控件,其ItemsSource设置为CollectionViewSource,包括PropertyGroupDescription以对ListView元素进行分组.CollectionViewSource看起来像这样:
<CollectionViewSource x:Key="ListViewObjects">
<CollectionViewSource.Source>
<Binding Path="CurrentListViewData"/>
</CollectionViewSource.Source>
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ObjectType" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
Run Code Online (Sandbox Code Playgroud)
在ListView中,我使用自定义组头,如下所示:
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin" Value="5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True">
<Expander.Header>
<DockPanel>
<TextBlock Text="{Binding Path=Items[0].ObjectType />
</DockPanel>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
Run Code Online (Sandbox Code Playgroud)
如您所见,Expander的IsExpanded属性设置为true.这意味着每当刷新ListView时,都会扩展所有Expander控件.
但是我想保存每个Expander的最后状态.我无法找到一种方法来保存每个ObjectType的Expander状态列表.我正在尝试使用绑定的HashTable和Converter,但是我没有将ObjectType作为ConverterParameter提供,因为它总是作为字符串传递.但这可能不是解决方案.
有人可以给我一个解决方案的提示或想法吗?:)
考虑这种情况:
153)id >= 153第4步安全吗?
也就是说,如果另一个请求几乎准确地同时进入,并在上面的步骤2之后插入另外20个记录,但在步骤4之前,是否会出现竞争条件?