public class BoardInsertAction extends BaseActionLogin
{
public ActionForward execute( ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)
{
DynaValidatorForm dForm = (DynaValidatorForm)form;
String title = dForm.get( "title" ).toString();
/*
게시판에 글을 입력하는 내용
*/
// 폼의 값들을 초기화하기 위해 reset함수 호출
dForm.reset( mapping , request );
return (mapping.findForward( "board_search_success" ));
}
}
DynaValidatorForm을 사용했을 경우 위의 경우처럼 reset을 써도
다시 폼으로 돌아가면 예전에 입력했던 값이 남아 있습니다.
ActionForm에서는 reset함수가 먹히지만 DynaValidator폼에서는 폼의 특성상
리셋이 되지 않는 것 같습니다.
입력을 다시 하려고 입력화면에 들어갔는데
예전에 입력한 값이 남아있으면 보기에 좋지 않겠죠?
이런 경우 리셋을 하는대신 폼의 값을 없애 버리면 문제를 해결할수 있습니다.
리셋 함수를 호출하는 대신
dForm.set( "title" , "" );
<= 요렇게 하면 예전에 입력한 값이 보이지 않게 됩니다. ^^
2013년 8월 8일 목요일
2013년 8월 3일 토요일
[JAVA AWT CARDLAYOUT교육]자바 AWT 카드레이아웃 (cardlayout) 예제
지금은 많이 쓰이지 않지만 JAVA AWT(Abstract Window ToolKit)은 자바 윈도우 프로그래밍의 중요한 부분 입니다. 참고하세요~~~
JAVA AWT 카드레이아웃 (cardlayout) 예제 .
오라클자바커뮤니티에서
설립한 오엔제이프로그래밍 실무교육센터
(오라클SQL,
튜닝, 힌트,자바프레임워크, 안드로이드,
아이폰, 닷넷 실무전문 강의)
import java.awt.*;
import java.awt.event.*;
import java.awt.event.*;
public class CardLayoutTest1 extends Frame {
public static void main(String[] args) {
Frame f = new Frame("CardLayoutTest");
final Panel tabs = new Panel();
tabs.add(new Button("<<"));
tabs.add(new Button("<"));
tabs.add(new Button("Options"));
tabs.add(new Button("Settings"));
tabs.add(new Button("Preferences"));
tabs.add(new Button(">"));
tabs.add(new Button(">>"));
f.add(tabs, "North");
final CardLayout layout = new CardLayout();
final Panel cards = new Panel(layout);
cards.add(new CardPanel("Options"), "Options");
cards.add(new CardPanel("Settings"), "Settings");
cards.add(new CardPanel("Preferences"), "Preferences");
f.add(cards, "Center");
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String cmd = ev.getActionCommand();
if (cmd.equals("<<")) layout.first(cards);
else if (cmd.equals("<")) layout.previous(cards);
else if (cmd.equals(">")) layout.next(cards);
else if (cmd.equals(">>")) layout.last(cards);
else layout.show(cards, cmd);
}
};
for(int i=0; i<tabs.getComponentCount();i++) {
((Button)tabs.getComponent(i)).addActionListener(al);
}
f.setSize(400, 300);
f.setVisible(true);
f.addWindowListener(new WindowListenerProcessing() );
}
}
public static void main(String[] args) {
Frame f = new Frame("CardLayoutTest");
final Panel tabs = new Panel();
tabs.add(new Button("<<"));
tabs.add(new Button("<"));
tabs.add(new Button("Options"));
tabs.add(new Button("Settings"));
tabs.add(new Button("Preferences"));
tabs.add(new Button(">"));
tabs.add(new Button(">>"));
f.add(tabs, "North");
final CardLayout layout = new CardLayout();
final Panel cards = new Panel(layout);
cards.add(new CardPanel("Options"), "Options");
cards.add(new CardPanel("Settings"), "Settings");
cards.add(new CardPanel("Preferences"), "Preferences");
f.add(cards, "Center");
ActionListener al = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String cmd = ev.getActionCommand();
if (cmd.equals("<<")) layout.first(cards);
else if (cmd.equals("<")) layout.previous(cards);
else if (cmd.equals(">")) layout.next(cards);
else if (cmd.equals(">>")) layout.last(cards);
else layout.show(cards, cmd);
}
};
for(int i=0; i<tabs.getComponentCount();i++) {
((Button)tabs.getComponent(i)).addActionListener(al);
}
f.setSize(400, 300);
f.setVisible(true);
f.addWindowListener(new WindowListenerProcessing() );
}
}
class CardPanel extends Panel {
CardPanel(String name) {
setLayout(new BorderLayout());
add(new Label("CardPanel : " + name, Label.CENTER),"Center");
Panel p = new Panel();
add(p, "South");
Button btn = new Button("Close");
ActionListener a1 = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String cmd = ev.getActionCommand();
if (cmd.equals("Close")) {
System.exit(0);
}
}
};
btn.addActionListener(a1);
p.add(btn);
}
}
CardPanel(String name) {
setLayout(new BorderLayout());
add(new Label("CardPanel : " + name, Label.CENTER),"Center");
Panel p = new Panel();
add(p, "South");
Button btn = new Button("Close");
ActionListener a1 = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
String cmd = ev.getActionCommand();
if (cmd.equals("Close")) {
System.exit(0);
}
}
};
btn.addActionListener(a1);
p.add(btn);
}
}
class WindowListenerProcessing extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}

피드 구독하기:
글 (Atom)